Boost logo

Boost :

Subject: Re: [boost] Movable but not copyable bug?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-08-25 17:49:19

Le 25/08/14 23:23, Peter Dimov a écrit :
> 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.
I guess that in C++11 Bar<Foo>() is an rvalue that better matches
Bar(Bar&&) than Bar(const &Bar), but with C++98 Bar<Foo>() is an rvalue
that matches better const &Bar than Bar(rv<Bar>) as the last need a
>> 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.

I suspect that Bar copy constructor should be available only if T is
copy constructible. Unfortunately I don't know a way to achieve this.


Boost list run by bdawes at, gregod at, cpdaniel at, john at