|
Boost : |
Subject: [boost] [move] const rvalue failure.
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2014-08-24 20:03:15
The following fails to compile on both g++ 4.8.2 and VS2005 using Boost
1.56:
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
struct MOC
{
MOC() : value(121) {}
MOC(BOOST_RV_REF(MOC) rhs) : value(rhs.value) {}
int value;
private:
//Declared and purposefully not defined.
MOC & operator=(MOC);
private:
BOOST_MOVABLE_BUT_NOT_COPYABLE(MOC)
};
MOC moveonlyMutableRValue()
{
return MOC();
}
MOC const moveonlyConstRValue()
{
return MOC();
}
int main()
{
MOC m(moveonlyConstRValue());
return 0;
}
with g++, I get the following error messages:
boost_move_const_rvalue.cc: In function âint main()â:
boost_move_const_rvalue.cc:28:30: error: invalid user-defined conversion
from âconst MOCâ to âboost::rv<MOC>&â [-fpermissive]
MOC m(moveonlyConstRValue());
^
In file included from boost_move_const_rvalue.cc:1:0:
/home/HPC/boost_installed/v1_56_0/include/boost/move/core.hpp:219:7: note:
candidate is: MOC::operator boost::rv<MOC>&() <near match>
operator ::boost::rv<TYPE>&() \
^
boost_move_const_rvalue.cc:13:3: note: in expansion of macro
âBOOST_MOVABLE_BUT_NOT_COPYABLEâ
BOOST_MOVABLE_BUT_NOT_COPYABLE(MOC)
^
/home/HPC/boost_installed/v1_56_0/include/boost/move/core.hpp:219:7:
note: no known conversion for implicit âthisâ parameter from âconst
MOC*â to âMOC*â
operator ::boost::rv<TYPE>&() \
^
boost_move_const_rvalue.cc:13:3: note: in expansion of macro
âBOOST_MOVABLE_BUT_NOT_COPYABLEâ
BOOST_MOVABLE_BUT_NOT_COPYABLE(MOC)
^
boost_move_const_rvalue.cc:28:30: error: passing âconst MOCâ as âthisâ
argument of âMOC::operator boost::rv<MOC>&()â discards qualifiers
[-fpermissive]
MOC m(moveonlyConstRValue());
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk