Format semantics:
Test other = toto();
includes multiple copies (but not the destination). The compiler is allowed however, all other instances exclude copies; almost all compilers do this optimization.
More specifically, the standard does not indicate where class type values are returned, but the usual solution is for the calling space and pass a hidden pointer to it in the function. Without the above optimizations:
Test
toto()
{
Test t;
return t;
}
t,
return t ,
. (
NRVO) , ,
t, t.
(, , t,
.)
:
Test t = toto();
Test,
toto, t .
,
t toto, .