
David Abrahams <dave@boostpro.com> writes:
on Fri Jan 09 2009, Ion GaztaƱaga <igaztanaga-AT-gmail.com> wrote:
on Thu Jan 08 2009, Ion GaztaƱaga <igaztanaga-AT-gmail.com> wrote:
The same happens when implementing forwarding functions, so I'm starting to think
David Abrahams wrote: that
putting T() in functions taking movable-only types by value is not a bad idea ;-)
Sorry, but what do you mean by "putting T() in functions?"
putting-milk-in-his-T'ly y'rs,
void function (movable m);
int main() { movable m; function(movable(boost::move(m))); function(movable()); return 0; }
I mean that to pass movable-only objects per-value you need to put movable() in the argument.
do you mean, generically, "movable(...)"? I couldn't tell whether you think the default-ctor-ness of that has significance.
This is needed if boost::move returns boost::detail::rv<T> instead of T.
But boost::move should return T.
Sorry for jumping in here, but I'm not sure that it should. Consider movable m; boost::move(m); In C++0x, move(m) is equivalent to static_cast<movable&&>(m), which just obtains a reference. If boost::move<T> returns a T then the code above will create a temporary which moves the data out of m, and then destroy that temporary, leaving m a hollow shell. Anthony -- Anthony Williams Author of C++ Concurrency in Action | http://www.manning.com/williams Custom Software Development | http://www.justsoftwaresolutions.co.uk Just Software Solutions Ltd, Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK