
Ion GaztaƱaga wrote:
On 28/05/2010 21:27, Ilya Sokolov wrote:
X(const X&) = delete; X& operator=(const X&) = delete;
Ok, but we are talking about rvalue references and asking if Boost.Move provokes some late error report. It's a shame we can't provoke a compilation error always (even with NVRO, I thought the compiler should check for the copy constructor, but I'm not an expert),
I'm not an expert either, but 12.2/1 of 14882:2003 clearly says so. AFAIR, msvc doesn't check.
but that's the best we can do.
template<class TYPE> class movable_but_not_copyable { TYPE(TYPE &); TYPE& operator=(TYPE &); public: operator ::BOOST_MOVE_NAMESPACE::rv<TYPE>&(); operator const ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() const; }; // from the original example class X : public movable_but_not_copyable { /*...*/ }; X X::create() { X x; return x; // compile-time error What do you think? Or even class noncopyable { // note: non-const ref noncopyable(noncopyable&); noncopyable& operator=(noncopyable&); }; template<class TYPE> struct movable { operator ::BOOST_MOVE_NAMESPACE::rv<TYPE>&(); operator const ::BOOST_MOVE_NAMESPACE::rv<TYPE>&() const; };