Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-09-17 17:09:25


Howard Hinnant wrote:
>
> You have to specify T if you want the assign functional to have a
> nested result_type of the correct type. This assures that the outer
> bind returns an T&. However I've just tested with:
>
> 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&.


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