Boost logo

Boost :

From: Fredrik Blomqvist (fredrik_blomqvist_at_[hidden])
Date: 2005-03-08 08:20:34


David Abrahams wrote:
> "Fredrik Blomqvist" <fredrik_blomqvist_at_[hidden]> writes:
>
>> Thorsten Ottosen wrote:
>>> "David Abrahams" <dave_at_[hidden]> wrote in message
>>> news:u1xar33ps.fsf_at_boost-consulting.com...
>>>
>>>> template< class Fun >
>>>> struct indirect_fun
>>>> {
>>>> indirect_fun( Fun f ) : fun(f)
>>>> { }
>>>>
>>>> template< class T >
>>>> typename
>>>> result_of<Fun(typename pointee<T>::type)>::type
>>>> operator()( T const& r ) const
>>>> { return fun( *r ); }
>>>
>>> yeah, this is good stuff, mind if I borrow it?
>>>
>> Wouldn't it be a good thing to use the full result_of "protocol" as
>> specified in the docs (and more specifically in the N1454) ?
>
> Namely what? Am I missing some cv qualification and references?
>
That indirect_fun would benefit from supplying the nested result<>
template that result_of uses to deduce return types.

Basically this is what I labelled the result_of "protocol" (for function
objects).
[from docs/1454 by Douglas Gregor]
"When F is a class type with a member type result_type, result_of<F(T1, T2,
..., TN)> is F::result_type. Otherwise, result_of<F(T1, T2, ..., TN)> is
F::result<F(T1, T2, ..., TN)>::type when N > 0 or void when N = 0."

Regards
// Fredrik Blomqvist


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