From 3d650b7f92fbb30d8e247d387cef44e130807ad3 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 23 Sep 2012 02:08:32 +0000 Subject: [PATCH] nicer work-around for gcc warnings [SVN r80656] --- .../boost/utility/detail/result_of_iterate.hpp | 8 +------- include/boost/utility/result_of.hpp | 15 ++++++++------- test/result_of_test.cpp | 12 ++++++++++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/boost/utility/detail/result_of_iterate.hpp b/include/boost/utility/detail/result_of_iterate.hpp index 7dccf17..23aa650 100644 --- a/include/boost/utility/detail/result_of_iterate.hpp +++ b/include/boost/utility/detail/result_of_iterate.hpp @@ -15,12 +15,6 @@ # error Boost result_of - do not include this file! #endif -// This header generate spurious warnings on gcc, which we supress by -// treating it as a system header. -#if defined(__GNUC__) && (__GNUC__ >= 4) -#pragma GCC system_header -#endif - // CWPro8 requires an argument in a function type specialization #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0 # define BOOST_RESULT_OF_ARGS void @@ -101,7 +95,7 @@ struct BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION()) { typedef typename BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())::type wrapper_t; static const bool value = ( sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type( - (boost::declval()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval() BOOST_PP_INTERCEPT)), 0) + (boost::declval()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval() BOOST_PP_INTERCEPT)), result_of_weird_type()) )) ); typedef mpl::bool_ type; diff --git a/include/boost/utility/result_of.hpp b/include/boost/utility/result_of.hpp index f6add2f..4695fa4 100644 --- a/include/boost/utility/result_of.hpp +++ b/include/boost/utility/result_of.hpp @@ -74,18 +74,19 @@ template struct tr1_result_of_im template T result_of_decay(T); -struct result_of_private_type -{ - result_of_private_type const &operator,(int) const; +struct result_of_private_type {}; + +struct result_of_weird_type { + template + friend result_of_weird_type operator,(T const &, 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 const &); +result_of_no_type result_of_is_private_type(result_of_weird_type); +result_of_yes_type result_of_is_private_type(result_of_private_type); template struct result_of_callable_class : C { diff --git a/test/result_of_test.cpp b/test/result_of_test.cpp index 0c2834f..61592f5 100644 --- a/test/result_of_test.cpp +++ b/test/result_of_test.cpp @@ -160,6 +160,10 @@ int main() typedef int (&func_ref)(float, double); typedef int (*func_ptr_0)(); typedef int (&func_ref_0)(); + typedef void (*func_ptr_void)(float, double); + typedef void (&func_ref_void)(float, double); + typedef void (*func_ptr_void_0)(); + typedef void (&func_ref_void_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; @@ -218,6 +222,10 @@ int main() 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, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::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)); @@ -228,6 +236,10 @@ int main() 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, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::value)); + BOOST_STATIC_ASSERT((is_same::type, void>::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));