|
Boost Users : |
Subject: [Boost-users] [move] Movable but not copyable bug?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2014-08-23 20:55:06
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?
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
struct Foo
{
Foo(int x, int y)
{}
Foo(BOOST_RV_REF(Foo) rhs)
{}
private:
//Purposefully declared and not defined.
Foo & operator=(Foo);
private:
BOOST_MOVABLE_BUT_NOT_COPYABLE(Foo)
};
template <typename T>
struct Bar
{
Bar()
: f(0, 1)
{}
// (1)
// Bar(Bar const & rhs)
// : f(rhs.f)
// {}
Bar(BOOST_RV_REF(Bar) rhs)
: f(::boost::move(rhs.f))
{}
private:
//Purposefully declared and not defined.
Bar & operator=(Bar);
private:
BOOST_COPYABLE_AND_MOVABLE(Bar)
private:
T f;
};
Foo f1()
{
// (2)
// Foo f(0, 1);
// return f;
// (3)
return Foo(0, 1);
}
Bar<Foo> f2()
{
return Bar<Foo>();
}
int main()
{
// Foo f( f1() );
Bar<Foo> b(Bar<Foo>());
return 0;
}
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