diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 035bf19..1ec857a 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -35,10 +35,7 @@ struct tr1_result_of #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 -// o->*f(x). This implementation supports both. +// Uses declval following N3225 20.7.7.6 when F is not a pointer. template struct result_of @@ -56,18 +53,15 @@ struct result_of namespace detail { -# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \ - static T ## n t ## n; \ - /**/ - template -class cpp0x_result_of_impl +struct cpp0x_result_of_impl { - static F f; - BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _) -public: - typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type; + typedef decltype( + boost::declval()( + BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), declval() BOOST_PP_INTERCEPT) + ) + ) type; }; } // namespace detail diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 9a42fd2..41cc176 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -22,6 +24,7 @@ #include #include #include +#include #ifndef BOOST_RESULT_OF_NUM_ARGS # define BOOST_RESULT_OF_NUM_ARGS 10 diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index a282a75..39f6c3b 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -98,6 +98,11 @@ struct no_result_type_or_result_of unsigned int operator()(); unsigned short operator()() volatile; const unsigned short operator()() const volatile; +#if !defined(BOOST_NO_RVALUE_REFERENCES) + short operator()(int&&); + int operator()(int&); + long operator()(int const&); +#endif }; template @@ -108,6 +113,11 @@ struct no_result_type_or_result_of_template unsigned int operator()(); unsigned short operator()() volatile; const unsigned short operator()() const volatile; +#if !defined(BOOST_NO_RVALUE_REFERENCES) + short operator()(int&&); + int operator()(int&); + long operator()(int const&); +#endif }; struct X {}; @@ -232,6 +242,14 @@ int main() BOOST_STATIC_ASSERT((is_same(double)>::type, short>::value)); BOOST_STATIC_ASSERT((is_same(void)>::type, unsigned short>::value)); BOOST_STATIC_ASSERT((is_same(void)>::type, const unsigned short>::value)); +#if !defined(BOOST_NO_RVALUE_REFERENCES) + BOOST_STATIC_ASSERT((is_same::type, short>::value)); + BOOST_STATIC_ASSERT((is_same::type, int>::value)); + BOOST_STATIC_ASSERT((is_same::type, long>::value)); + BOOST_STATIC_ASSERT((is_same(int&&)>::type, short>::value)); + BOOST_STATIC_ASSERT((is_same(int&)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(int const&)>::type, long>::value)); +#endif #endif return 0; diff --git a/utility.htm b/utility.htm index 3ac5d42..e2cbfd7 100644 --- a/utility.htm +++ b/utility.htm @@ -224,6 +224,20 @@ typedef boost::result_of< >::type type; +

In a future + release, BOOST_RESULT_OF_USE_DECLTYPE + may be enabled by default on compilers that + support decltype, so if you use the above + protocol please take care to ensure that + the result_type + and result<> members accurately + represent the result type. If you wish to continue to + use the protocol on compilers that + support decltype, + use boost::tr1_result_of, which is also + defined + in <boost/utility/result_of.hpp>.

+

This implementation of result_of requires class template partial specialization, the