From 63cde4d3fd724c3eecba9e38e6f2f3f7fcb508ee Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 8 Jan 2007 20:38:51 +0000 Subject: [PATCH] slightly modified implementation works around msvc 7.1/8.0 compiler bugs [SVN r36668] --- .../utility/detail/result_of_iterate.hpp | 14 +++++------ include/boost/utility/result_of.hpp | 11 ++++----- test/result_of_test.cpp | 24 +++++++++++++++++++ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 06c4203..2c148bc 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -21,21 +21,21 @@ template struct result_of - : detail::result_of_impl {}; + : detail::result_of_impl::value)> {}; #endif namespace detail { template -struct result_of_impl +struct result_of_impl { typedef R type; }; template -struct result_of_impl +struct result_of_impl { typedef R type; }; @@ -47,7 +47,7 @@ template struct result_of_impl + FArgs, false> { typedef R type; }; @@ -57,7 +57,7 @@ template + FArgs, false> { typedef R type; }; @@ -67,7 +67,7 @@ template + FArgs, false> { typedef R type; }; @@ -77,7 +77,7 @@ template + FArgs, false> { typedef R type; }; diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index 4db448e..5c5c3d2 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -29,28 +29,25 @@ namespace detail { BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) -template struct get_result_of; +template struct result_of_impl; template -struct get_result_of +struct result_of_impl { typedef typename F::result_type type; }; template -struct get_result_of +struct result_of_impl : F::template result {}; template -struct get_result_of +struct result_of_impl { typedef void type; }; -template -struct result_of_impl : get_result_of::value)> {}; - } // end namespace detail #define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,)) diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index af7aba2..ea48e73 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -24,6 +24,24 @@ struct int_result_type_and_float_result_of template struct result { typedef float type; }; }; +template +struct int_result_type_template { typedef int result_type; }; + +template +struct int_result_of_template +{ + template struct result; + template struct result { typedef int type; }; +}; + +template +struct int_result_type_and_float_result_of_template +{ + typedef int result_type; + template struct result; + template struct result { typedef float type; }; +}; + struct X {}; int main() @@ -43,6 +61,12 @@ int main() BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, void>::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(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(double)>::type, int>::value)); + BOOST_STATIC_ASSERT((is_same(void)>::type, void>::value)); + BOOST_STATIC_ASSERT((is_same(char)>::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));