Subject: Re: [boost] Movable but not copyable bug?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2014-08-25 19:36:56
On Mon, 25 Aug 2014 16:18:28 -0700, Peter Dimov <lists_at_[hidden]> wrote:
> Mostafa wrote:
>> Then why is it that in C++03 with g++ 4.8.2 the code sample compiles if
>> the copy ctor for Bar is not explicitly defined?
> C++03 12.8/5:
> The implicitly-declared copy constructor for a class X will have the form
> X::X(const X&)
> â each direct or virtual base class B of X has a copy constructor whose
> first parameter is of type const
> B& or const volatile B&, and
> â for all the nonstatic data members of X that are of a class type M (or
> array thereof), each such class type
> has a copy constructor whose first parameter is of type const M& or
> const volatile M&.107)
> Otherwise, the implicitly declared copy constructor will have the form
> My guess is that Boost.Move declares Foo's copy constructor to take
> Foo&. This causes Bar's implicit copy constructor to take Bar&, which
> doesn't match rvalues.
(Filling in the details.)
Ah, so in that case Bar's move ctor is selected:
because "Bar<Foo>()" is implicitly convertible to BOOST_RV_REF(Bar).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk