Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 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 | // Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012. |
| 9 | // Use, modification and distribution is subject to the Boost Software |
| 10 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or |
| 11 | // copy at http://www.boost.org/LICENSE_1_0.txt) |
| 12 | |
| 13 | // For more information, see http://www.boost.org/libs/utility |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 14 | #if !defined(NDNBOOST_PP_IS_ITERATING) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 15 | # error Boost result_of - do not include this file! |
| 16 | #endif |
| 17 | |
| 18 | // CWPro8 requires an argument in a function type specialization |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 19 | #if NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3002)) && NDNBOOST_PP_ITERATION() == 0 |
| 20 | # define NDNBOOST_RESULT_OF_ARGS void |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 21 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 22 | # define NDNBOOST_RESULT_OF_ARGS NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 23 | #endif |
| 24 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 25 | #if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551)) |
| 26 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 27 | struct tr1_result_of<F(NDNBOOST_RESULT_OF_ARGS)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 28 | : mpl::if_< |
| 29 | mpl::or_< is_pointer<F>, is_member_function_pointer<F> > |
| 30 | , ndnboost::detail::tr1_result_of_impl< |
| 31 | typename remove_cv<F>::type, |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 32 | typename remove_cv<F>::type(NDNBOOST_RESULT_OF_ARGS), |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 33 | (ndnboost::detail::has_result_type<F>::value)> |
| 34 | , ndnboost::detail::tr1_result_of_impl< |
| 35 | F, |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 36 | F(NDNBOOST_RESULT_OF_ARGS), |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 37 | (ndnboost::detail::has_result_type<F>::value)> >::type { }; |
| 38 | #endif |
| 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 40 | #ifdef NDNBOOST_RESULT_OF_USE_DECLTYPE |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 41 | |
| 42 | // Uses declval following N3225 20.7.7.6 when F is not a pointer. |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 43 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 44 | struct result_of<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T))> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 45 | : mpl::if_< |
| 46 | is_member_function_pointer<F> |
| 47 | , detail::tr1_result_of_impl< |
| 48 | typename remove_cv<F>::type, |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 49 | typename remove_cv<F>::type(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), false |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 50 | > |
| 51 | , detail::cpp0x_result_of_impl< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 52 | F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 53 | > |
| 54 | >::type |
| 55 | {}; |
| 56 | |
| 57 | namespace detail { |
| 58 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 59 | #ifdef NDNBOOST_NO_SFINAE_EXPR |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 60 | |
| 61 | template<typename F> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 62 | struct NDNBOOST_PP_CAT(result_of_callable_fun_2_, NDNBOOST_PP_ITERATION()); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 63 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 64 | template<typename R NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(), typename T)> |
| 65 | struct NDNBOOST_PP_CAT(result_of_callable_fun_2_, NDNBOOST_PP_ITERATION())<R(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(), T))> { |
| 66 | R operator()(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(), T)) const; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 67 | typedef result_of_private_type const &(*pfn_t)(...); |
| 68 | operator pfn_t() const volatile; |
| 69 | }; |
| 70 | |
| 71 | template<typename F> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 72 | struct NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION()); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 73 | |
| 74 | template<typename F> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 75 | struct NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION())<F *> |
| 76 | : NDNBOOST_PP_CAT(result_of_callable_fun_2_, NDNBOOST_PP_ITERATION())<F> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 77 | {}; |
| 78 | |
| 79 | template<typename F> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | struct NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION())<F &> |
| 81 | : NDNBOOST_PP_CAT(result_of_callable_fun_2_, NDNBOOST_PP_ITERATION())<F> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 82 | {}; |
| 83 | |
| 84 | template<typename F> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 85 | struct NDNBOOST_PP_CAT(result_of_select_call_wrapper_type_, NDNBOOST_PP_ITERATION()) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 86 | : mpl::eval_if< |
| 87 | is_class<typename remove_reference<F>::type>, |
| 88 | result_of_wrap_callable_class<F>, |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 89 | mpl::identity<NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION())<typename remove_cv<F>::type> > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 90 | > |
| 91 | {}; |
| 92 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 93 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(), typename T)> |
| 94 | struct NDNBOOST_PP_CAT(result_of_is_callable_, NDNBOOST_PP_ITERATION()) { |
| 95 | typedef typename NDNBOOST_PP_CAT(result_of_select_call_wrapper_type_, NDNBOOST_PP_ITERATION())<F>::type wrapper_t; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 96 | static const bool value = ( |
| 97 | sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type( |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 98 | (ndnboost::declval<wrapper_t>()(NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT)), result_of_weird_type()) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 99 | )) |
| 100 | ); |
| 101 | typedef mpl::bool_<value> type; |
| 102 | }; |
| 103 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 104 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 105 | struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), true> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 106 | : lazy_enable_if< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | NDNBOOST_PP_CAT(result_of_is_callable_, NDNBOOST_PP_ITERATION())<F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(), T)> |
| 108 | , cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), false> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 109 | > |
| 110 | {}; |
| 111 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 112 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 113 | struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), false> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 114 | { |
| 115 | typedef decltype( |
| 116 | ndnboost::declval<F>()( |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 117 | NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 118 | ) |
| 119 | ) type; |
| 120 | }; |
| 121 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 122 | #else // NDNBOOST_NO_SFINAE_EXPR |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 123 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 124 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 125 | struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 126 | typename result_of_always_void<decltype( |
| 127 | ndnboost::declval<F>()( |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 128 | NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 129 | ) |
| 130 | )>::type> { |
| 131 | typedef decltype( |
| 132 | ndnboost::declval<F>()( |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 133 | NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 134 | ) |
| 135 | ) type; |
| 136 | }; |
| 137 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 138 | #endif // NDNBOOST_NO_SFINAE_EXPR |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 139 | |
| 140 | } // namespace detail |
| 141 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 142 | #else // defined(NDNBOOST_RESULT_OF_USE_DECLTYPE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 143 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 144 | #if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551)) |
| 145 | template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 146 | struct result_of<F(NDNBOOST_RESULT_OF_ARGS)> |
| 147 | : tr1_result_of<F(NDNBOOST_RESULT_OF_ARGS)> { }; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 148 | #endif |
| 149 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 150 | #endif // defined(NDNBOOST_RESULT_OF_USE_DECLTYPE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 151 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 152 | #undef NDNBOOST_RESULT_OF_ARGS |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 153 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 154 | #if NDNBOOST_PP_ITERATION() >= 1 |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 155 | |
| 156 | namespace detail { |
| 157 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 158 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 159 | struct tr1_result_of_impl<R (*)(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), FArgs, false> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 160 | { |
| 161 | typedef R type; |
| 162 | }; |
| 163 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 164 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
| 165 | struct tr1_result_of_impl<R (&)(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), FArgs, false> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 166 | { |
| 167 | typedef R type; |
| 168 | }; |
| 169 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 170 | #if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551)) |
| 171 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 172 | struct tr1_result_of_impl<R (T0::*) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 173 | (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T)), |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 174 | FArgs, false> |
| 175 | { |
| 176 | typedef R type; |
| 177 | }; |
| 178 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 179 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 180 | struct tr1_result_of_impl<R (T0::*) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 181 | (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 182 | const, |
| 183 | FArgs, false> |
| 184 | { |
| 185 | typedef R type; |
| 186 | }; |
| 187 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 188 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 189 | struct tr1_result_of_impl<R (T0::*) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 190 | (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 191 | volatile, |
| 192 | FArgs, false> |
| 193 | { |
| 194 | typedef R type; |
| 195 | }; |
| 196 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 197 | template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 198 | struct tr1_result_of_impl<R (T0::*) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 199 | (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 200 | const volatile, |
| 201 | FArgs, false> |
| 202 | { |
| 203 | typedef R type; |
| 204 | }; |
| 205 | #endif |
| 206 | |
| 207 | } |
| 208 | #endif |