mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
A note about RVO
This commit is contained in:
parent
4a2af140e4
commit
85f6ba0b57
@ -262,7 +262,10 @@ string retVal = tempObjectFun();
|
|||||||
// - the returned object is destroyed
|
// - the returned object is destroyed
|
||||||
// The returned object is called a temporary object. Temporary objects are
|
// The returned object is called a temporary object. Temporary objects are
|
||||||
// created whenever a function returns an object, and they are destroyed at the
|
// created whenever a function returns an object, and they are destroyed at the
|
||||||
// end of the evaluation of the enclosing expression. So in this code:
|
// end of the evaluation of the enclosing expression (Well, this is what the
|
||||||
|
// standard says, but compilers are allowed to change this behavior. Look up
|
||||||
|
// "return value optimization" if you're into this kind of details). So in this
|
||||||
|
// code:
|
||||||
foo(bar(tempObjectFun()))
|
foo(bar(tempObjectFun()))
|
||||||
|
|
||||||
// assuming `foo` and `bar` exist, the object returned from `tempObjectFun` is
|
// assuming `foo` and `bar` exist, the object returned from `tempObjectFun` is
|
||||||
|
Loading…
Reference in New Issue
Block a user