El 25/08/2014 23:23, Peter Dimov escribió:
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.
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.
Yes, but he is compiling in C++03, that's why he's getting: error: passing ‘const Foo’ as ‘this’ argument of ‘Foo::operator boost::rv<Foo>&()’ discards qualifiers [-fpermissive] In C++03 both will require the copy constructor (I think). Best, Ion