]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // (C) Copyright John Maddock 2005. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #ifdef TEST_STD_HEADERS | |
7 | #include <functional> | |
8 | #else | |
9 | #include <boost/tr1/functional.hpp> | |
10 | #endif | |
11 | ||
12 | #include <boost/static_assert.hpp> | |
13 | #include <boost/type_traits/is_same.hpp> | |
14 | ||
15 | struct int_result_type { typedef int result_type; }; | |
16 | ||
17 | struct int_result_of | |
18 | { | |
19 | template<typename F> struct result { typedef int type; }; | |
20 | }; | |
21 | ||
22 | struct int_result_type_and_float_result_of | |
23 | { | |
24 | typedef int result_type; | |
25 | template<typename F> struct result { typedef float type; }; | |
26 | }; | |
27 | ||
28 | struct X {}; | |
29 | ||
30 | int main() | |
31 | { | |
32 | typedef int (*func_ptr)(float, double); | |
33 | typedef int (&func_ref)(float, double); | |
34 | typedef int (X::*mem_func_ptr)(float); | |
35 | typedef int (X::*mem_func_ptr_c)(float) const; | |
36 | typedef int (X::*mem_func_ptr_v)(float) volatile; | |
37 | typedef int (X::*mem_func_ptr_cv)(float) const volatile; | |
38 | ||
39 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<int_result_type(float)>::type, int>::value)); | |
40 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<int_result_of(double)>::type, int>::value)); | |
41 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<int_result_of(void)>::type, void>::value)); | |
42 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<const int_result_of(double)>::type, int>::value)); | |
43 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<volatile int_result_of(void)>::type, void>::value)); | |
44 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<int_result_type_and_float_result_of(char)>::type, int>::value)); | |
45 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<func_ptr(char, float)>::type, int>::value)); | |
46 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<func_ref(char, float)>::type, int>::value)); | |
47 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<mem_func_ptr(X,char)>::type, int>::value)); | |
48 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<mem_func_ptr_c(X,char)>::type, int>::value)); | |
49 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<mem_func_ptr_v(X,char)>::type, int>::value)); | |
50 | BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::result_of<mem_func_ptr_cv(X,char)>::type, int>::value)); | |
51 | return 0; | |
52 | } | |
53 |