struct S 
{
	double operator()(char, int&);
};

int main()
{
  boost::result_of<S(char, int&)>::type f = 3.14; // f has type double
}

OS : win7
compiler :gcc mingw4.6.2

error message :
error: no class template named 'result' in 'struct S'|
error: expected ';' before 'f'|
error: 'type' is not a member of 'boost::result_of<S(char, int&)>'|

according to
http://en.cppreference.com/w/cpp/types/result_of

This should work, what am I lack?Thanks

Use std::result_of<> instead of boost::result_of<>

#include <functional>

struct S
{
    double operator() ( char, int& ) const ; // omitting const here is a (very) bad idea
};

int main()
{
    return sizeof( std::result_of< S(char, int&) >::type ) == sizeof(double) ;
}

From Boost documentation:
"If decltype is not enabled, then automatic result type deduction of function objects is not possible. Instead, result_of uses the following protocol to allow the programmer to specify a type. When F is a class type with a member type result_type, result_of<F(T1, T2, ..., TN)> is F::result_type. When F does not contain result_type, result_of<F(T1, T2, ..., TN)> is F::result<F(T1, T2, ..., TN)>::type when N > 0 or void when N = 0. Note that it is the responsibility of the programmer to ensure that function objects accurately advertise their result type via this protocol"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.