Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-09-17 18:26:57

On Sep 17, 2003, at 6:09 PM, Peter Dimov wrote:

>> struct assign
>> {
>> template <class T, class U>
>> T& operator()(T& t, const U& u) const
>> {return t = u;}
>> };
>> ...
>> bind(assign(), bind(&X::member, _1), value)(x);
>> and it works as well. However the resulting functional did not return
>> a T&. To achieve that one could also:
>> T& j = bind<T&>(assign(), bind(&X::member, _1), value)(x); // returns
>> T& now
> The alternative is to add a result_of<assign(T, U)> specialization to
> tell
> bind that assign()(t, u) returns T&.

<nod> So true. Or even better, pester your favorite vendor or national
standards body into a reference preserving decltype. ;-)

Seriously, for those who may be listening who are not sure of the value
of a reference preserving decltype (or typeof), this work was a /royal/
pain in the rear because of the lack of this feature. If we had such
an animal, result_of would just work (as would mem_fn(M T*::) and


Boost list run by bdawes at, gregod at, cpdaniel at, john at