From 66514f61ff23d377f02f051a1600772613bfaef0 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 24 Jan 2007 06:44:20 +0000 Subject: [PATCH] fix result_of ambiguity error for nullary functions [SVN r36773] --- .../utility/detail/result_of_iterate.hpp | 13 +++++++---- include/boost/utility/result_of.hpp | 23 ++++++++++++++++--- test/result_of_test.cpp | 7 ++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 2c148bc..fa0ab89 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -24,25 +24,27 @@ struct result_of : detail::result_of_impl::value)> {}; #endif +#undef BOOST_RESULT_OF_ARGS + +#if BOOST_PP_ITERATION() >= 1 + 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; }; -#undef BOOST_RESULT_OF_ARGS - -#if BOOST_PP_ITERATION() > 1 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) template struct result_of_impl struct result_of_impl; +template +struct result_of_void_impl +{ + typedef void type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + +template +struct result_of_void_impl +{ + typedef R type; +}; + template struct result_of_impl { @@ -44,9 +62,8 @@ struct result_of_impl template struct result_of_impl -{ - typedef void type; -}; + : result_of_void_impl +{}; } // end namespace detail diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index ea48e73..ca1cfae 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -50,10 +50,13 @@ int main() typedef int (*func_ptr)(float, double); typedef int (&func_ref)(float, double); + typedef int (*func_ptr_0)(); + typedef int (&func_ref_0)(); typedef int (X::*mem_func_ptr)(float); typedef int (X::*mem_func_ptr_c)(float) const; typedef int (X::*mem_func_ptr_v)(float) volatile; typedef int (X::*mem_func_ptr_cv)(float) const volatile; + typedef int (X::*mem_func_ptr_0)(); BOOST_STATIC_ASSERT((is_same::type, int>::value)); BOOST_STATIC_ASSERT((is_same::type, int>::value)); @@ -69,9 +72,13 @@ int main() 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)); + 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)); + return 0; }