There is no such thing as "lvalue object". The only temporary here is result of the expression
f()
(when copy elision is disabled).
For reference, I suppose "myObject" refers to this line from the linked stackoverflow Q&A
1 2 3 4
|
int main()
{
Foo myObject = f();
}
|
In post-1992 C++ the following happens:
1) The declaration at line 3 of f() creates a local variable of type Foo on the stack frame of the main function. It is accessible under the name 'cubbi' within the scope of f() and under the name 'myObject' within the scope of main.
If you were to disable all copy elisions but use C++11 (so there is such a thing as move), the following would happen:
1) The declaration at line 3 of f() creates a local variable cubbi of type Foo on the stack frame of f().
2) The return statement looks up constructors of Foo that would take an rvalue Foo as an argument. Foo(Foo&&) is a match, and that constructor is called to initialize the Foo temporary that is the result of f() (that "placeholder" you're asking about), with cubbi (treated as rvalue so it binds) as the argument.
3) the destructor of cubbi runs as f()'s stack frame is undone
4) the main function now looks up constructors of Foo that would take an rvalue Foo as an argument. Foo(Foo&&) is a match, and that constructor is called to initialize myObject, which is a local variable on the stack frame of the main function
5) the destructor of the Foo temporary (originally created by f()'s return statement and gutted by mObject's move constructor) runs
(note, your stackoverflow question was concerning a different f(), one that executed "
return Foo("Hello");
")