On Jul 14, 11:51 am, "Leigh Johnston" <le...@i42.co.uk> wrote:
It is obvious to me at least that the innards of GetMyClass is not part
of
the expression used to invoke GetMyClass.
Agreed. But the temp won't be destroyed on the return from
the innards of GetMyClass. It'll be destroyed at the sequence
point after the call to GetMyClass, no? Ex.,
const MyClass& GetMyClass(const MyClass& t) { return t; }
...
MyClass a;
a = GetMyClass(MyClass());
Doesn't the sequence point (and thus destruction of the
temp) not happen until after operator=() is done?
Supposing the temp is not destructed, I think the reference
is still valid.
It's seems to me to be as valid as say
MyClass& MyClass::operator*=(int) { return *this; }
a = MyClass().operator*=(5);
Both return a reference to a temp, and both cases the temp
still lives to be assigned from.
What am I missing?
--Jonathan
see my post else-thread for more info.