Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:10:10

0001 // Boost result_of library
0002 
0003 //  Copyright Douglas Gregor 2004. Use, modification and
0004 //  distribution is subject to the Boost Software License, Version
0005 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 // For more information, see http://www.boost.org/libs/utility
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 // BOOST_UTILITY_DOCS
0044 
0045 // Use the decltype-based version of result_of by default if the compiler
0046 // supports N3276 <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf>.
0047 // The user can force the choice by defining BOOST_RESULT_OF_USE_DECLTYPE,
0048 // BOOST_RESULT_OF_USE_TR1, or BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK but not more than one!
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 // this implies !defined(BOOST_NO_CXX11_DECLTYPE)
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 // BOOST_UTILITY_DOCS
0069 
0070 namespace boost {
0071 
0072 template<typename F> struct result_of;
0073 template<typename F> struct tr1_result_of; // a TR1-style implementation of result_of
0074 
0075 #if !defined(BOOST_NO_SFINAE)
0076 namespace detail {
0077 
0078 typedef char result_of_yes_type;      // sizeof(result_of_yes_type) == 1
0079 typedef char (&result_of_no_type)[2]; // sizeof(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 // Work around a nvcc bug by only defining has_result when it's needed.
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 // There doesn't seem to be any other way to turn this off such that the presence of
0121 // the user-defined operator,() below doesn't cause spurious warning all over the place,
0122 // so unconditionally and globally turn it off. (https://svn.boost.org/trac10/ticket/7663)
0123 #ifdef BOOST_MSVC
0124 #  pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
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) // assignment operator could not be generated.
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 // BOOST_NO_SFINAE_EXPR
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 // BOOST_NO_SFINAE_EXPR
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 // Determine the return type of a function pointer or pointer to member.
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 } // end namespace detail
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 // inform dependency trackers, as they can't see through macro includes
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 // BOOST_RESULT_OF_HPP