From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-02-09 16:41:02
David Abrahams wrote:
> Howard Hinnant <hinnant_at_[hidden]> writes:
>> On Feb 9, 2004, at 11:33 AM, Peter Dimov wrote:
>>> However (apologies for the follow up to self) the rest of Howard's
>>> still seems to apply, i.e. the CA temporary is created with A::A(A&&),
>>> the A const & parameter of foo is bound directly to that temporary
>>> (if not elided).
>> And thanks for the corrected analysis.
> I don't know. If that analysis were correct, then Comeau would give
> the same error for this snippet in my example.
> typedef X const XC;
> but instead I see:
> ------ test 20, direct initialize a const A with an A -------
> X() #24
> MOVE #25 <== #24
> in const lvalue sink2
> destroy #25
> destroy #24 (EMPTY)
That's because your "move" constructor is not a move constructor from
language point of view (i.e. it has no special status). As I understand it,
the compiler's thought process goes somewhat like: need to create a
temporary, but it can be elided, so we'll just access check the copy
constructor. The compiler doesn't want to backtrack and try not to elide the
temporary, which would've succeeded.
X::X(X&&), if it existed and operated like we proposed, would enjoy the same
special status as the copy constructor, and the compiler would know that it
can be elided as it creates an object that is equivalent to the old value of
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk