diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 6f1b2b1..8de00b4 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -22,7 +22,8 @@ struct result_of : mpl::if_< mpl::or_< is_pointer, is_member_function_pointer > , detail::result_of_impl< - F, F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false + typename remove_cv::type, + typename remove_cv::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false > , detail::result_of_decltype_impl< F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)) @@ -61,7 +62,16 @@ public: template struct result_of - : boost::detail::result_of_impl::value)> {}; + : 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 { }; #endif #undef BOOST_RESULT_OF_ARGS diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 07306d6..d8baa3e 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #ifndef BOOST_RESULT_OF_NUM_ARGS # define BOOST_RESULT_OF_NUM_ARGS 10 @@ -56,6 +57,11 @@ 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 + : result_of_impl::type, FArgs, false> { }; + template struct result_of_impl { diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index c6e91ea..73dc757 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -177,6 +177,10 @@ int main() 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)); + #if defined(BOOST_HAS_DECLTYPE) BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, unsigned int>::value));