Boost logo

Boost :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-11-22 19:15:35


On Nov 22, 2004, at 7:05 PM, Brock Peabody wrote:

> I replaced my home grown result_type<> with boost::result_of<> today
> only to
> find that I couldn't get it to work. When I try to use result_of with
> VC
> 7.1:
>
> struct test_struct {
>
> typedef int result_type;
> };
>
> boost::result_of<test_struct>::type i = 5;
>
> I get:
>
> test.cpp(10) : error C2027: use of undefined type
> 'boost::result_of<F>'
>
> I get the same results if I use function types of pointer to function
> types:
>
> boost::result_of<int (*)()>::type i = 5;
> boost::result_of<int ()()>::type i = 5;
>
> Am I missing something?

Yes :)

With result_of, you pass the function object type _and_ the types of
the arguments, e.g.,

        boost::result_of<test_struct(int, float)>::type

That's how result_of is able to deal with polymorphic function objects.

        Doug


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