A note about RVO

This commit is contained in:
Geoff Liu 2015-09-02 00:46:30 -06:00
parent 4a2af140e4
commit 85f6ba0b57

View File

@ -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