|
1 // Boost result_of library |
|
2 |
|
3 // Copyright Douglas Gregor 2004. Use, modification and |
|
4 // distribution is subject to the Boost Software License, Version |
|
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|
6 // http://www.boost.org/LICENSE_1_0.txt) |
|
7 |
|
8 // For more information, see http://www.boost.org/libs/utility |
|
9 #ifndef BOOST_RESULT_OF_HPP |
|
10 #define BOOST_RESULT_OF_HPP |
|
11 |
|
12 #include <boost/config.hpp> |
|
13 #include <boost/type_traits/ice.hpp> |
|
14 #include <boost/type.hpp> |
|
15 #include <boost/preprocessor.hpp> |
|
16 #include <boost/detail/workaround.hpp> |
|
17 #include <boost/mpl/has_xxx.hpp> |
|
18 #include <boost/mpl/if.hpp> |
|
19 #include <boost/mpl/bool.hpp> |
|
20 |
|
21 #ifndef BOOST_RESULT_OF_NUM_ARGS |
|
22 # define BOOST_RESULT_OF_NUM_ARGS 10 |
|
23 #endif |
|
24 |
|
25 namespace boost { |
|
26 |
|
27 template<typename F> struct result_of; |
|
28 |
|
29 #if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
|
30 namespace detail { |
|
31 |
|
32 BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) |
|
33 |
|
34 template<typename F, typename FArgs, bool HasResultType> struct result_of_impl; |
|
35 |
|
36 template<typename F> |
|
37 struct result_of_void_impl |
|
38 { |
|
39 typedef void type; |
|
40 }; |
|
41 |
|
42 template<typename R> |
|
43 struct result_of_void_impl<R (*)(void)> |
|
44 { |
|
45 typedef R type; |
|
46 }; |
|
47 |
|
48 template<typename R> |
|
49 struct result_of_void_impl<R (&)(void)> |
|
50 { |
|
51 typedef R type; |
|
52 }; |
|
53 |
|
54 template<typename F, typename FArgs> |
|
55 struct result_of_impl<F, FArgs, true> |
|
56 { |
|
57 typedef typename F::result_type type; |
|
58 }; |
|
59 |
|
60 template<typename FArgs> |
|
61 struct is_function_with_no_args : mpl::false_ {}; |
|
62 |
|
63 template<typename F> |
|
64 struct is_function_with_no_args<F(void)> : mpl::true_ {}; |
|
65 |
|
66 template<typename F, typename FArgs> |
|
67 struct result_of_nested_result : F::template result<FArgs> |
|
68 {}; |
|
69 |
|
70 template<typename F, typename FArgs> |
|
71 struct result_of_impl<F, FArgs, false> |
|
72 : mpl::if_<is_function_with_no_args<FArgs>, |
|
73 result_of_void_impl<F>, |
|
74 result_of_nested_result<F, FArgs> >::type |
|
75 {}; |
|
76 |
|
77 } // end namespace detail |
|
78 |
|
79 #define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>)) |
|
80 #include BOOST_PP_ITERATE() |
|
81 |
|
82 #else |
|
83 # define BOOST_NO_RESULT_OF 1 |
|
84 #endif |
|
85 |
|
86 } |
|
87 |
|
88 #endif // BOOST_RESULT_OF_HPP |