diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index fe24a47..d653844 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -30,11 +30,11 @@ struct tr1_result_of , 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::result_of_has_result_type::value)> , boost::detail::tr1_result_of_impl< F, F(BOOST_RESULT_OF_ARGS), - (boost::detail::has_result_type::value)> >::type { }; + (boost::detail::result_of_has_result_type::value)> >::type { }; #endif #ifdef BOOST_RESULT_OF_USE_DECLTYPE @@ -46,7 +46,7 @@ struct result_of #ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK template struct result_of - : conditional::value || detail::has_result::value, + : conditional::value || detail::result_of_has_result::value, tr1_result_of, detail::cpp0x_result_of >::type { }; #endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 2976737..2b652ba 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -45,10 +44,6 @@ 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 @@ -69,11 +64,40 @@ template struct tr1_result_of; // a TR1-style implementation of resu #if !defined(BOOST_NO_SFINAE) namespace detail { -BOOST_MPL_HAS_XXX_TRAIT_DEF(result_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 struct result_of_has_type {}; + +template struct result_of_has_result_type_impl +{ + template static result_of_yes_type f( result_of_has_type* ); + template static result_of_no_type f( ... ); + + typedef boost::integral_constant(0)) == sizeof(result_of_yes_type)> type; +}; + +template struct result_of_has_result_type: result_of_has_result_type_impl::type +{ +}; // Work around a nvcc bug by only defining has_result when it's needed. #ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK -BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result) + +template class C> struct result_of_has_template {}; + +template struct result_of_has_result_impl +{ + template static result_of_yes_type f( result_of_has_template* ); + template static result_of_no_type f( ... ); + + typedef boost::integral_constant(0)) == sizeof(result_of_yes_type)> type; +}; + +template struct result_of_has_result: result_of_has_result_impl::type +{ +}; + #endif template struct tr1_result_of_impl; @@ -95,9 +119,6 @@ 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);