$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Movable but not copyable bug?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2014-08-25 19:05:11
On Mon, 25 Aug 2014 15:23:23 -0700, Ion Gaztañaga <igaztanaga_at_[hidden]>
wrote:
> El 25/08/2014 23:23, Peter Dimov escribió:
>> Ion Gaztañaga wrote:
>>
>>> Maybe you should design your code in C++11 and port it to Boost.Move,
>>> you might get better compiler help.
>>
>> His code compiles in C++11, as is.
>>
>>> If this copy constructor is instantiated, and in many compilers
>>>
>>> Bar<Foo> b(( Bar<Foo>() ));
>>>
>>> requires the copy constructor, then you get a compilation error. Just
>>> try this equivalent (but more inefficient) code:
>>>
>>> Bar<Foo> a;
>>> Bar<Foo> b(a);
>>
>> This is not equivalent. a is an lvalue here. In the above code,
>> Bar<Foo>() is an rvalue. It should use the move constructor, not the
>> copy constructor.
>
> Yes, but he is compiling in C++03, that's why he's getting:
>
> error: passing âconst Fooâ as âthisâ argument of âFoo::operator
> boost::rv<Foo>&()â discards qualifiers [-fpermissive]
>
> In C++03 both will require the copy constructor (I think).
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? My understanding is that
in that case the copy ctor is *not* deleted, because the following
compiles:
// (3)
Bar<int> b2(( Bar<int>() ));
(Note, the definition of Foo's ctor has been changed to just take one arg
and Bar's ctor has been updated accordingly.)