Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-02-11 21:55:45


Powell, Gary wrote:
>>fnresult is only used to work around the rvalue to const& binding
>>problem. I'm not sure I understand what Rani has been saying, but it
>>seems like whatever applies here would apply to Mojo as well.
>>So AFAICT:
>>if it works with Dave's code, it should work with Mojo. I
>>might as well
>>be wrong though.
>>
>
>
> I think that without using Dave's approach to removing the const T & constructor you have to have all these other MOJO types. Dave's approach does the right thing for non const r-value's returned by functions. Including the operator=() stuff. Without a special Mojo type mojo does not.

I don't understand this. The difference between Dave's approach and Mojo
is the technique used to discriminate between rvalues and const
lvalues.

   struct X : mojo<X>
   {
       X(X&);
       X(temporary<X>);
       X(constant<X>); // HERE
   };

   struct X : new_way<X>
   {
       X(X&);
       X(temporary<X>);

       template<class T>
       X(T&, typename enable_same<X const, T>::type = 0); // HERE
   };

> The beauty of move.cpp is that you only have to modify the class not the functions which you may not have control of.

This is true for Mojo as well, except for working around const& binding.

> If the question is whether to use inheritence to gain move semantics, I think I answered that already, and it works pretty well.
>
> What fails for both of them is that the const &T contructor has to be visible to the compiler even if its not called or used. And whether that is the correct action is the current point of discussion.

Right. And if it isn't the correct action both ways will work equally
well.

-- 
Daniel Wallin

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk