X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Futility%2Fresult_of.hpp;fp=boost%2Futility%2Fresult_of.hpp;h=a530c3ac2539b94feb97499d9c3df4617979e258;hp=0000000000000000000000000000000000000000;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/utility/result_of.hpp b/boost/utility/result_of.hpp new file mode 100644 index 0000000..a530c3a --- /dev/null +++ b/boost/utility/result_of.hpp @@ -0,0 +1,207 @@ +// Boost result_of library + +// Copyright Douglas Gregor 2004. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// For more information, see http://www.boost.org/libs/utility +#ifndef BOOST_RESULT_OF_HPP +#define BOOST_RESULT_OF_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef BOOST_RESULT_OF_NUM_ARGS +# define BOOST_RESULT_OF_NUM_ARGS 16 +#endif + +// Use the decltype-based version of result_of by default if the compiler +// supports N3276 . +// The user can force the choice by defining BOOST_RESULT_OF_USE_DECLTYPE, +// BOOST_RESULT_OF_USE_TR1, or BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK but not more than one! +#if (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1)) || \ + (defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)) || \ + (defined(BOOST_RESULT_OF_USE_TR1) && defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)) +# error More than one of BOOST_RESULT_OF_USE_DECLTYPE, BOOST_RESULT_OF_USE_TR1 and \ + BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK cannot be defined at the same time. +#endif + +#if defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK) && defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE) +# error Cannot fallback to decltype if BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE is not defined. +#endif + +#ifndef BOOST_RESULT_OF_USE_TR1 +# ifndef BOOST_RESULT_OF_USE_DECLTYPE +# ifndef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK +# ifndef BOOST_NO_CXX11_DECLTYPE_N3276 // this implies !defined(BOOST_NO_CXX11_DECLTYPE) +# define BOOST_RESULT_OF_USE_DECLTYPE +# else +# define BOOST_RESULT_OF_USE_TR1 +# endif +# endif +# endif +#endif + +namespace boost { + +template struct result_of; +template struct tr1_result_of; // a TR1-style implementation of result_of + +#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +namespace detail { + +BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) + +BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result) + +template struct tr1_result_of_impl; + +template struct cpp0x_result_of; + +#ifdef BOOST_NO_SFINAE_EXPR + +// There doesn't seem to be any other way to turn this off such that the presence of +// the user-defined operator,() below doesn't cause spurious warning all over the place, +// so unconditionally turn it off. +#if BOOST_MSVC +# pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used +#endif + +struct result_of_private_type {}; + +struct result_of_weird_type { + friend result_of_private_type operator,(result_of_private_type, result_of_weird_type); +}; + +typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1 +typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2 + +template +result_of_no_type result_of_is_private_type(T const &); +result_of_yes_type result_of_is_private_type(result_of_private_type); + +template +struct result_of_callable_class : C { + result_of_callable_class(); + typedef result_of_private_type const &(*pfn_t)(...); + operator pfn_t() const volatile; +}; + +template +struct result_of_wrap_callable_class { + typedef result_of_callable_class type; +}; + +template +struct result_of_wrap_callable_class { + typedef result_of_callable_class const type; +}; + +template +struct result_of_wrap_callable_class { + typedef result_of_callable_class volatile type; +}; + +template +struct result_of_wrap_callable_class { + typedef result_of_callable_class const volatile type; +}; + +template +struct result_of_wrap_callable_class { + typedef typename result_of_wrap_callable_class::type &type; +}; + +template struct cpp0x_result_of_impl; + +#else // BOOST_NO_SFINAE_EXPR + +template +struct result_of_always_void +{ + typedef void type; +}; + +template struct cpp0x_result_of_impl {}; + +#endif // BOOST_NO_SFINAE_EXPR + +template +struct result_of_void_impl +{ + typedef void type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + +// Determine the return type of a function pointer or pointer to member. +template +struct result_of_pointer + : tr1_result_of_impl::type, FArgs, false> { }; + +template +struct tr1_result_of_impl +{ + typedef typename F::result_type type; +}; + +template +struct is_function_with_no_args : mpl::false_ {}; + +template +struct is_function_with_no_args : mpl::true_ {}; + +template +struct result_of_nested_result : F::template result +{}; + +template +struct tr1_result_of_impl + : mpl::if_, + result_of_void_impl, + result_of_nested_result >::type +{}; + +} // end namespace detail + +#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,)) +#include BOOST_PP_ITERATE() + +#else +# define BOOST_NO_RESULT_OF 1 +#endif + +} + +#endif // BOOST_RESULT_OF_HPP