2003-02-22 21:38:38 +00:00
|
|
|
#include <boost/result_of.hpp>
|
|
|
|
|
#include <utility>
|
|
|
|
|
#include <boost/static_assert.hpp>
|
|
|
|
|
#include <boost/type_traits/is_same.hpp>
|
|
|
|
|
|
|
|
|
|
class int_result_type { typedef int result_type; };
|
|
|
|
|
|
|
|
|
|
class int_result_of
|
|
|
|
|
{
|
2004-01-05 21:27:28 +00:00
|
|
|
template<typename F> struct result { typedef int type; };
|
2003-02-22 21:38:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class int_result_type_and_float_result_of
|
|
|
|
|
{
|
|
|
|
|
typedef int result_type;
|
2004-01-05 21:27:28 +00:00
|
|
|
template<typename F> struct result { typedef float type; };
|
2003-02-22 21:38:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct X {};
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
using namespace boost;
|
|
|
|
|
|
|
|
|
|
typedef int (*func_ptr)(float, double);
|
|
|
|
|
typedef int (X::*mem_func_ptr)(float);
|
|
|
|
|
|
|
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
|
|
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
|
2004-01-05 21:27:28 +00:00
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
|
2003-02-22 21:38:38 +00:00
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
|
|
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
|
|
|
|
|
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr(X,char)>::type, int>::value));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|