Boost logo

Boost :

Subject: Re: [boost] Checking for return types (result_of) - redux..
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-08-21 10:29:52


AMDG

Edward Grace wrote:
> So, I have nearly figured out what to do, however it seems --
> deliberately in fact, that the behaviour of result_of<???> is
> different when passed a function and a functor.

The type of a function pointer is unsigned(*)(). The return type
is easily deducible from the type of the function pointer.
For function objects, you need to use result_type or result,
since it is impossible to deduce the result type automatically

> <snip>
>
> struct one_functor {
> // This is apparently needed if we want to use result_of<..> on
> nullary functors like this.
> // typedef unsigned result_type;
> unsigned operator()() { return 1; }
> };

In the current standard it is impossible to deduce the result
without using the result_type typedef. In C++0x, result_of
is specified using decltype, so it won't be necessary.

In Christ,
Steven Watanabe


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