mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
Fix example code in F.20. (#1109)
This commit is contained in:
committed by
Sergey Zubkov
parent
044a4b277e
commit
bd948ee839
@@ -2997,9 +2997,9 @@ Such older advice is now obsolete; it does not add value, and it interferes with
|
|||||||
vector<int> g(const vector<int>& vx)
|
vector<int> g(const vector<int>& vx)
|
||||||
{
|
{
|
||||||
// ...
|
// ...
|
||||||
f() = vx; // prevented by the "const"
|
fct() = vx; // prevented by the "const"
|
||||||
// ...
|
// ...
|
||||||
return f(); // expensive copy: move semantics suppressed by the "const"
|
return fct(); // expensive copy: move semantics suppressed by the "const"
|
||||||
}
|
}
|
||||||
|
|
||||||
The argument for adding `const` to a return value is that it prevents (very rare) accidental access to a temporary.
|
The argument for adding `const` to a return value is that it prevents (very rare) accidental access to a temporary.
|
||||||
|
|||||||
Reference in New Issue
Block a user