Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-03-01 15:16:26


"Jonathan Turkanis" <technews_at_[hidden]> wrote

> Because the type expression passed to result_of must be of the form
> F(arg1, ..., argN).
>
> The correct way to use result_of with function pointers is as follows:

[original example snip]

This also works :

#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/result_of.hpp>

typedef int (*f)(int); // <-- no change

int main()
{
    typedef boost::result_of<f(double,bool,long,char,int)>::type
result_type1;
    typedef boost::result_of<f()>::type result_type2;
    BOOST_STATIC_ASSERT((boost::is_same<result_type1,
result_type2>::value));
}

IOW the args are 'sugar' in the function pointer/ref case.

regards
Andy Little


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