Index: boost/utility/detail/result_of_iterate.hpp =================================================================== --- boost/utility/detail/result_of_iterate.hpp (revision 61207) +++ boost/utility/detail/result_of_iterate.hpp (working copy) @@ -10,8 +10,31 @@ # error Boost result_of - do not include this file! #endif -#if defined(BOOST_HAS_DECLTYPE) +// CWPro8 requires an argument in a function type specialization +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 +# define BOOST_RESULT_OF_ARGS void +#else +# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T) +#endif +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +template +struct tr1_result_of + : mpl::if_< + mpl::or_< is_pointer, is_member_function_pointer > + , boost::detail::tr1_result_of_impl< + typename remove_cv::type, + typename remove_cv::type(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> + , boost::detail::tr1_result_of_impl< + F, + F(BOOST_RESULT_OF_ARGS), + (boost::detail::has_result_type::value)> >::type { }; +#endif + +#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE) + // As of N2588, C++0x result_of only supports function call // expressions of the form f(x). This precludes support for member // function pointers, which are invoked with expressions of the form @@ -21,11 +44,11 @@ struct result_of : mpl::if_< mpl::or_< is_pointer, is_member_function_pointer > - , detail::result_of_impl< + , detail::tr1_result_of_impl< typename remove_cv::type, typename remove_cv::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false > - , detail::result_of_decltype_impl< + , detail::cpp0x_result_of_impl< F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)) > >::type @@ -39,7 +62,7 @@ template -class result_of_decltype_impl +class cpp0x_result_of_impl { static F f; BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _) @@ -51,47 +74,31 @@ #else // defined(BOOST_NO_DECLTYPE) -// CWPro8 requires an argument in a function type specialization -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 -# define BOOST_RESULT_OF_ARGS void -#else -# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T) -#endif - #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template struct result_of - : mpl::if_< - mpl::or_< is_pointer, is_member_function_pointer > - , boost::detail::result_of_impl< - typename remove_cv::type, - typename remove_cv::type(BOOST_RESULT_OF_ARGS), - (boost::detail::has_result_type::value)> - , boost::detail::result_of_impl< - F, - F(BOOST_RESULT_OF_ARGS), - (boost::detail::has_result_type::value)> >::type { }; + : tr1_result_of { }; #endif +#endif // defined(BOOST_NO_DECLTYPE) + #undef BOOST_RESULT_OF_ARGS -#endif // defined(BOOST_NO_DECLTYPE) - #if BOOST_PP_ITERATION() >= 1 namespace detail { template -struct result_of_impl +struct tr1_result_of_impl { typedef R type; }; template -struct result_of_impl +struct tr1_result_of_impl { typedef R type; }; @@ -99,7 +106,7 @@ #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template -struct result_of_impl { @@ -108,7 +115,7 @@ template -struct result_of_impl @@ -118,7 +125,7 @@ template -struct result_of_impl @@ -128,7 +135,7 @@ template -struct result_of_impl Index: boost/utility/result_of.hpp =================================================================== --- boost/utility/result_of.hpp (revision 61207) +++ boost/utility/result_of.hpp (working copy) @@ -30,14 +30,15 @@ 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) -template struct result_of_impl; -template struct result_of_decltype_impl; +template struct tr1_result_of_impl; +template struct cpp0x_result_of_impl; template struct result_of_void_impl @@ -60,10 +61,10 @@ // Determine the return type of a function pointer or pointer to member. template struct result_of_pointer - : result_of_impl::type, FArgs, false> { }; + : tr1_result_of_impl::type, FArgs, false> { }; template -struct result_of_impl +struct tr1_result_of_impl { typedef typename F::result_type type; }; @@ -79,7 +80,7 @@ {}; template -struct result_of_impl +struct tr1_result_of_impl : mpl::if_, result_of_void_impl, result_of_nested_result >::type Index: boost/tr1/functional.hpp =================================================================== --- boost/tr1/functional.hpp (revision 61207) +++ boost/tr1/functional.hpp (working copy) @@ -48,7 +48,10 @@ namespace std{ namespace tr1{ - using ::boost::result_of; + template + struct result_of + : ::boost::tr1_result_of + {}; } } Index: libs/utility/test/result_of_test.cpp =================================================================== --- libs/utility/test/result_of_test.cpp (revision 61207) +++ libs/utility/test/result_of_test.cpp (working copy) @@ -5,6 +5,8 @@ // 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#define BOOST_RESULT_OF_USE_DECLTYPE + // For more information, see http://www.boost.org/libs/utility #include #include @@ -131,6 +133,18 @@ BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(float)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + // Prior to decltype, result_of could not deduce the return type // nullary function objects unless they exposed a result_type. #if !defined(BOOST_NO_DECLTYPE) @@ -145,6 +159,9 @@ BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); #endif + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(char)>::type, int>::value)); + // Prior to decltype, result_of ignored a nested result<> if // result_type was defined. After decltype, result_of deduces the // actual return type of the function object, ignoring both @@ -168,6 +185,17 @@ BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, double>::value)); BOOST_STATIC_ASSERT((is_same::type, const double>::value)); BOOST_STATIC_ASSERT((is_same::type, volatile double>::value)); @@ -177,10 +205,22 @@ BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + BOOST_STATIC_ASSERT((is_same::type, double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const double>::value)); + BOOST_STATIC_ASSERT((is_same::type, volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, const volatile double>::value)); + BOOST_STATIC_ASSERT((is_same::type, int &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int volatile &>::value)); + BOOST_STATIC_ASSERT((is_same::type, int const volatile &>::value)); + typedef int (*pf_t)(int); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type,int>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type,int>::value)); + #if !defined(BOOST_NO_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value));