Boost logo

Boost Users :

Subject: Re: [Boost-users] [move] Movable but not copyable bug?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-08-24 03:12:29


El 24/08/2014 2:55, Mostafa escribió:
> Given the following code, if (1) is uncommented then it fails to compile
> under C++03 mode yet works in C++11 mode. If commented out, then it
> compiles successfully under both modes. (g++ 4.8.2 is being used) Is this
> behavior expected or a bug?

> private:
> //Purposefully declared and not defined.
> Foo & operator=(Foo);

BOOST_MOVABLE_BUT_NOT_COPYABLE(Foo) already makes copy assignment
private. See Boost.Move documentation.

Returning by value requires CopyConstructible in C++03 compilers. If you
declare that operation in Bar, then the compiler will use it. If you
leave it out, Boost.Move magic will make moveable-only objects
returnable by value.

I think that you need BOOST_MOVE_RET to obtain portable behaviour:

http://www.boost.org/doc/libs/1_56_0/doc/html/BOOST_MOVE_RET.html

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net