File indexing completed on 2025-12-15 10:10:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_RESULT_OF_HPP
0010 #define BOOST_RESULT_OF_HPP
0011
0012 #include <boost/config.hpp>
0013 #include <boost/detail/workaround.hpp>
0014 #include <boost/type_traits/is_class.hpp>
0015 #include <boost/type_traits/is_pointer.hpp>
0016 #include <boost/type_traits/is_member_function_pointer.hpp>
0017 #include <boost/type_traits/remove_cv.hpp>
0018 #include <boost/type_traits/remove_reference.hpp>
0019 #include <boost/type_traits/declval.hpp>
0020 #include <boost/type_traits/conditional.hpp>
0021 #include <boost/type_traits/type_identity.hpp>
0022 #include <boost/type_traits/integral_constant.hpp>
0023 #include <boost/core/enable_if.hpp>
0024
0025 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0026 # undef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
0027 # define BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
0028 #endif
0029 #ifdef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
0030 # include <boost/preprocessor/cat.hpp>
0031 # include <boost/preprocessor/iteration/iterate.hpp>
0032 # include <boost/preprocessor/repetition/enum_params.hpp>
0033 # include <boost/preprocessor/repetition/enum_trailing_params.hpp>
0034 # include <boost/preprocessor/repetition/enum_binary_params.hpp>
0035 # include <boost/preprocessor/repetition/enum_shifted_params.hpp>
0036 # include <boost/preprocessor/facilities/intercept.hpp>
0037 #endif
0038
0039 #ifndef BOOST_UTILITY_DOCS
0040 #ifndef BOOST_RESULT_OF_NUM_ARGS
0041 # define BOOST_RESULT_OF_NUM_ARGS 16
0042 #endif
0043 #endif
0044
0045
0046
0047
0048
0049 #if (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1)) || \
0050 (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)) || \
0051 (defined(BOOST_RESULT_OF_USE_TR1) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK))
0052 # error More than one of BOOST_RESULT_OF_USE_DECLTYPE, BOOST_RESULT_OF_USE_TR1 and \
0053 BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK cannot be defined at the same time.
0054 #endif
0055
0056 #ifndef BOOST_UTILITY_DOCS
0057 #ifndef BOOST_RESULT_OF_USE_TR1
0058 # ifndef BOOST_RESULT_OF_USE_DECLTYPE
0059 # ifndef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
0060 # ifndef BOOST_NO_CXX11_DECLTYPE_N3276
0061 # define BOOST_RESULT_OF_USE_DECLTYPE
0062 # else
0063 # define BOOST_RESULT_OF_USE_TR1
0064 # endif
0065 # endif
0066 # endif
0067 #endif
0068 #endif
0069
0070 namespace boost {
0071
0072 template<typename F> struct result_of;
0073 template<typename F> struct tr1_result_of;
0074
0075 #if !defined(BOOST_NO_SFINAE)
0076 namespace detail {
0077
0078 typedef char result_of_yes_type;
0079 typedef char (&result_of_no_type)[2];
0080
0081 template<class T> struct result_of_has_type {};
0082
0083 template<class T> struct result_of_has_result_type_impl
0084 {
0085 template<class U> static result_of_yes_type f( result_of_has_type<typename U::result_type>* );
0086 template<class U> static result_of_no_type f( ... );
0087
0088 typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
0089 };
0090
0091 template<class T> struct result_of_has_result_type: result_of_has_result_type_impl<T>::type
0092 {
0093 };
0094
0095
0096 #ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
0097
0098 template<template<class> class C> struct result_of_has_template {};
0099
0100 template<class T> struct result_of_has_result_impl
0101 {
0102 template<class U> static result_of_yes_type f( result_of_has_template<U::template result>* );
0103 template<class U> static result_of_no_type f( ... );
0104
0105 typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
0106 };
0107
0108 template<class T> struct result_of_has_result: result_of_has_result_impl<T>::type
0109 {
0110 };
0111
0112 #endif
0113
0114 template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
0115
0116 template<typename F> struct cpp0x_result_of;
0117
0118 #ifdef BOOST_NO_SFINAE_EXPR
0119
0120
0121
0122
0123 #ifdef BOOST_MSVC
0124 # pragma warning(disable: 4913)
0125 #endif
0126
0127 struct result_of_private_type {};
0128
0129 struct result_of_weird_type {
0130 friend result_of_private_type operator,(result_of_private_type, result_of_weird_type);
0131 };
0132
0133 template<typename T>
0134 result_of_no_type result_of_is_private_type(T const &);
0135 result_of_yes_type result_of_is_private_type(result_of_private_type);
0136
0137 #ifdef BOOST_MSVC
0138 # pragma warning(push)
0139 # pragma warning(disable: 4512)
0140 #endif
0141 template<typename C>
0142 struct result_of_callable_class : C {
0143 result_of_callable_class();
0144 typedef result_of_private_type const &(*pfn_t)(...);
0145 operator pfn_t() const volatile;
0146 };
0147 #ifdef BOOST_MSVC
0148 # pragma warning(pop)
0149 #endif
0150
0151 template<typename C>
0152 struct result_of_wrap_callable_class {
0153 typedef result_of_callable_class<C> type;
0154 };
0155
0156 template<typename C>
0157 struct result_of_wrap_callable_class<C const> {
0158 typedef result_of_callable_class<C> const type;
0159 };
0160
0161 template<typename C>
0162 struct result_of_wrap_callable_class<C volatile> {
0163 typedef result_of_callable_class<C> volatile type;
0164 };
0165
0166 template<typename C>
0167 struct result_of_wrap_callable_class<C const volatile> {
0168 typedef result_of_callable_class<C> const volatile type;
0169 };
0170
0171 template<typename C>
0172 struct result_of_wrap_callable_class<C &> {
0173 typedef typename result_of_wrap_callable_class<C>::type &type;
0174 };
0175
0176 template<typename F, bool TestCallability = true> struct cpp0x_result_of_impl;
0177
0178 #else
0179
0180 template<typename T>
0181 struct result_of_always_void
0182 {
0183 typedef void type;
0184 };
0185
0186 template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
0187
0188 #endif
0189
0190 template<typename F>
0191 struct result_of_void_impl
0192 {
0193 typedef void type;
0194 };
0195
0196 template<typename R>
0197 struct result_of_void_impl<R (*)(void)>
0198 {
0199 typedef R type;
0200 };
0201
0202 template<typename R>
0203 struct result_of_void_impl<R (&)(void)>
0204 {
0205 typedef R type;
0206 };
0207
0208
0209 template<typename F, typename FArgs>
0210 struct result_of_pointer
0211 : tr1_result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
0212
0213 template<typename F, typename FArgs>
0214 struct tr1_result_of_impl<F, FArgs, true>
0215 {
0216 typedef typename F::result_type type;
0217 };
0218
0219 template<typename FArgs>
0220 struct is_function_with_no_args : false_type {};
0221
0222 template<typename F>
0223 struct is_function_with_no_args<F(void)> : true_type {};
0224
0225 template<typename F, typename FArgs>
0226 struct result_of_nested_result : F::template result<FArgs>
0227 {};
0228
0229 template<typename F, typename FArgs>
0230 struct tr1_result_of_impl<F, FArgs, false>
0231 : conditional<is_function_with_no_args<FArgs>::value,
0232 result_of_void_impl<F>,
0233 result_of_nested_result<F, FArgs> >::type
0234 {};
0235
0236 }
0237
0238 #ifndef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
0239 # include <boost/utility/detail/result_of_variadic.hpp>
0240 #else
0241 # define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
0242 # include BOOST_PP_ITERATE()
0243 #endif
0244
0245 #if 0
0246
0247 #include <boost/utility/detail/result_of_iterate.hpp>
0248 #endif
0249
0250 #else
0251 # define BOOST_NO_RESULT_OF 1
0252 #endif
0253
0254 }
0255
0256 #endif