blob: 96298a4c29eb4920802e660c314916c5a061f03c [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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 Thompson3d613fd2013-10-15 15:39:04 -070014#if !defined(NDNBOOST_PP_IS_ITERATING)
Jeff Thompsona28eed82013-08-22 16:21:10 -070015# error Boost result_of - do not include this file!
16#endif
17
18// CWPro8 requires an argument in a function type specialization
Jeff Thompson3d613fd2013-10-15 15:39:04 -070019#if NDNBOOST_WORKAROUND(__MWERKS__, NDNBOOST_TESTED_AT(0x3002)) && NDNBOOST_PP_ITERATION() == 0
20# define NDNBOOST_RESULT_OF_ARGS void
Jeff Thompsona28eed82013-08-22 16:21:10 -070021#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070022# define NDNBOOST_RESULT_OF_ARGS NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070023#endif
24
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025#if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551))
26template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
27struct tr1_result_of<F(NDNBOOST_RESULT_OF_ARGS)>
Jeff Thompsona28eed82013-08-22 16:21:10 -070028 : 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 Thompson3d613fd2013-10-15 15:39:04 -070032 typename remove_cv<F>::type(NDNBOOST_RESULT_OF_ARGS),
Jeff Thompsona28eed82013-08-22 16:21:10 -070033 (ndnboost::detail::has_result_type<F>::value)>
34 , ndnboost::detail::tr1_result_of_impl<
35 F,
Jeff Thompson3d613fd2013-10-15 15:39:04 -070036 F(NDNBOOST_RESULT_OF_ARGS),
Jeff Thompsona28eed82013-08-22 16:21:10 -070037 (ndnboost::detail::has_result_type<F>::value)> >::type { };
38#endif
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040#ifdef NDNBOOST_RESULT_OF_USE_DECLTYPE
Jeff Thompsona28eed82013-08-22 16:21:10 -070041
42// Uses declval following N3225 20.7.7.6 when F is not a pointer.
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
44struct result_of<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T))>
Jeff Thompsona28eed82013-08-22 16:21:10 -070045 : mpl::if_<
46 is_member_function_pointer<F>
47 , detail::tr1_result_of_impl<
48 typename remove_cv<F>::type,
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049 typename remove_cv<F>::type(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), false
Jeff Thompsona28eed82013-08-22 16:21:10 -070050 >
51 , detail::cpp0x_result_of_impl<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070052 F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T))
Jeff Thompsona28eed82013-08-22 16:21:10 -070053 >
54 >::type
55{};
56
57namespace detail {
58
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059#ifdef NDNBOOST_NO_SFINAE_EXPR
Jeff Thompsona28eed82013-08-22 16:21:10 -070060
61template<typename F>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070062struct NDNBOOST_PP_CAT(result_of_callable_fun_2_, NDNBOOST_PP_ITERATION());
Jeff Thompsona28eed82013-08-22 16:21:10 -070063
Jeff Thompson3d613fd2013-10-15 15:39:04 -070064template<typename R NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(), typename T)>
65struct 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 Thompsona28eed82013-08-22 16:21:10 -070067 typedef result_of_private_type const &(*pfn_t)(...);
68 operator pfn_t() const volatile;
69};
70
71template<typename F>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070072struct NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION());
Jeff Thompsona28eed82013-08-22 16:21:10 -070073
74template<typename F>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070075struct 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 Thompsona28eed82013-08-22 16:21:10 -070077{};
78
79template<typename F>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080struct 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 Thompsona28eed82013-08-22 16:21:10 -070082{};
83
84template<typename F>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070085struct NDNBOOST_PP_CAT(result_of_select_call_wrapper_type_, NDNBOOST_PP_ITERATION())
Jeff Thompsona28eed82013-08-22 16:21:10 -070086 : mpl::eval_if<
87 is_class<typename remove_reference<F>::type>,
88 result_of_wrap_callable_class<F>,
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089 mpl::identity<NDNBOOST_PP_CAT(result_of_callable_fun_, NDNBOOST_PP_ITERATION())<typename remove_cv<F>::type> >
Jeff Thompsona28eed82013-08-22 16:21:10 -070090 >
91{};
92
Jeff Thompson3d613fd2013-10-15 15:39:04 -070093template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(), typename T)>
94struct 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 Thompsona28eed82013-08-22 16:21:10 -070096 static const bool value = (
97 sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098 (ndnboost::declval<wrapper_t>()(NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT)), result_of_weird_type())
Jeff Thompsona28eed82013-08-22 16:21:10 -070099 ))
100 );
101 typedef mpl::bool_<value> type;
102};
103
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
105struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), true>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700106 : lazy_enable_if<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 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 Thompsona28eed82013-08-22 16:21:10 -0700109 >
110{};
111
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700112template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
113struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), false>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700114{
115 typedef decltype(
116 ndnboost::declval<F>()(
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700117 NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700118 )
119 ) type;
120};
121
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700122#else // NDNBOOST_NO_SFINAE_EXPR
Jeff Thompsona28eed82013-08-22 16:21:10 -0700123
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700124template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
125struct cpp0x_result_of_impl<F(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)),
Jeff Thompsona28eed82013-08-22 16:21:10 -0700126 typename result_of_always_void<decltype(
127 ndnboost::declval<F>()(
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700128 NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700129 )
130 )>::type> {
131 typedef decltype(
132 ndnboost::declval<F>()(
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700133 NDNBOOST_PP_ENUM_BINARY_PARAMS(NDNBOOST_PP_ITERATION(), ndnboost::declval<T, >() NDNBOOST_PP_INTERCEPT)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700134 )
135 ) type;
136};
137
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700138#endif // NDNBOOST_NO_SFINAE_EXPR
Jeff Thompsona28eed82013-08-22 16:21:10 -0700139
140} // namespace detail
141
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700142#else // defined(NDNBOOST_RESULT_OF_USE_DECLTYPE)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700143
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700144#if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551))
145template<typename F NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
146struct result_of<F(NDNBOOST_RESULT_OF_ARGS)>
147 : tr1_result_of<F(NDNBOOST_RESULT_OF_ARGS)> { };
Jeff Thompsona28eed82013-08-22 16:21:10 -0700148#endif
149
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700150#endif // defined(NDNBOOST_RESULT_OF_USE_DECLTYPE)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700151
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700152#undef NDNBOOST_RESULT_OF_ARGS
Jeff Thompsona28eed82013-08-22 16:21:10 -0700153
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700154#if NDNBOOST_PP_ITERATION() >= 1
Jeff Thompsona28eed82013-08-22 16:21:10 -0700155
156namespace detail {
157
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700158template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
159struct tr1_result_of_impl<R (*)(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), FArgs, false>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700160{
161 typedef R type;
162};
163
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700164template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
165struct tr1_result_of_impl<R (&)(NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_ITERATION(),T)), FArgs, false>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700166{
167 typedef R type;
168};
169
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700170#if !NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x551))
171template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700172struct tr1_result_of_impl<R (T0::*)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700173 (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T)),
Jeff Thompsona28eed82013-08-22 16:21:10 -0700174 FArgs, false>
175{
176 typedef R type;
177};
178
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700179template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700180struct tr1_result_of_impl<R (T0::*)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700181 (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700182 const,
183 FArgs, false>
184{
185 typedef R type;
186};
187
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700188template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700189struct tr1_result_of_impl<R (T0::*)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700190 (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700191 volatile,
192 FArgs, false>
193{
194 typedef R type;
195};
196
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700197template<typename R, typename FArgs NDNBOOST_PP_ENUM_TRAILING_PARAMS(NDNBOOST_PP_ITERATION(),typename T)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700198struct tr1_result_of_impl<R (T0::*)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700199 (NDNBOOST_PP_ENUM_SHIFTED_PARAMS(NDNBOOST_PP_ITERATION(),T))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700200 const volatile,
201 FArgs, false>
202{
203 typedef R type;
204};
205#endif
206
207}
208#endif