
David Abrahams escribió:
Only in assignments?
what about
consume(produce())
scenarios?
obj produce() { return obj(); } void consume(obj ){} int main() { consume(produce()); return 0; } At least in MSVC 7.1, GCC 4.3 and Intel 10.0 (which is EDG 3.8, http://software.intel.com/en-us/articles/intel-c-compiler-for-windows-genera...) this produces just a default constructor and no calls to copy constructor. And the same happens with: obj o = produce(); and obj o(produce());
This is not the case with constructors (the original Klaus Triendl proposal included them, http://lists.boost.org/Archives/boost/2009/06/153266.php) because it terribly uglifies syntax
Are you sure you've looked at all the alternatives? Every move library I'm aware of before yours supports implicitly move constructing from non-const rvalues.
Well, I can't say I've looked all of them ;-). I think this alternative is one of the most balanced ones, and allows writing optimal code for c++0x compilers without creating temporaries. Regards, Ion