Given this piece of code:
#include
(void) someFunction(void) {
list l;
l.push_back(1);
}
The answer you selected is incorrect about 1 thing...
returning a list does not call the list's copy constructor.
list func()
{
list res; // &res returns 0x7fff183f0900
res.push_back(10);
return res;
}
list l = func(); // &l also returns 0x7fff183f0900 (no copy)
You can double check this by printing &res in the function and &l outside the function.
The compiler is optimized to pass through returned objects without making copies, otherwise every single non-pointer object returned would be copied, which would be insane.