mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #992 from isocpp/broken-links
Replace broken links to #Rf-pass-ref-ref and #Rf-pass-ref-move
This commit is contained in:
commit
cf223f3cb8
|
@ -2840,7 +2840,7 @@ For advanced uses (only), where you really need to optimize for rvalues passed t
|
|||
Avoid "esoteric techniques" such as:
|
||||
|
||||
* Passing arguments as `T&&` "for efficiency".
|
||||
Most rumors about performance advantages from passing by `&&` are false or brittle (but see [F.25](#Rf-pass-ref-move).)
|
||||
Most rumors about performance advantages from passing by `&&` are false or brittle (but see [F.18](#Rf-consume) and [F.19](#Rf-forward).)
|
||||
* Returning `const T&` from assignments and similar operations (see [F.47](#Rf-assignment-op).)
|
||||
|
||||
##### Example
|
||||
|
@ -3580,7 +3580,7 @@ Flag functions where no `return` expression could yield `nullptr`
|
|||
|
||||
##### Reason
|
||||
|
||||
It's asking to return a reference to a destroyed temporary object. A `&&` is a magnet for temporary objects. This is fine when the reference to the temporary is being passed "downward" to a callee, because the temporary is guaranteed to outlive the function call. (See [F.24](#Rf-pass-ref-ref) and [F.25](#Rf-pass-ref-move).) However, it's not fine when passing such a reference "upward" to a larger caller scope. See also ???.
|
||||
It's asking to return a reference to a destroyed temporary object. A `&&` is a magnet for temporary objects. This is fine when the reference to the temporary is being passed "downward" to a callee, because the temporary is guaranteed to outlive the function call (see [F.18](#Rf-consume) and [F.19](#Rf-forward)). However, it's not fine when passing such a reference "upward" to a larger caller scope. See also ???.
|
||||
|
||||
For passthrough functions that pass in parameters (by ordinary reference or by perfect forwarding) and want to return values, use simple `auto` return type deduction (not `auto&&`).
|
||||
|
||||
|
@ -5633,7 +5633,7 @@ Types can be defined to move for logical as well as performance reasons.
|
|||
|
||||
##### Reason
|
||||
|
||||
It is simple and efficient. If you want to optimize for rvalues, provide an overload that takes a `&&` (see [F.24](#Rf-pass-ref-ref)).
|
||||
It is simple and efficient. If you want to optimize for rvalues, provide an overload that takes a `&&` (see [F.18](#Rf-consume)).
|
||||
|
||||
##### Example
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user