From 4f7c036ba96dd5e557e95e24a73cb00f8daff042 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 13 Mar 2002 22:16:06 +0000 Subject: [PATCH] Considerably simplified is_reference for MSVC is_reference and is_enum now works with ABCs! [SVN r13186] --- .../boost/type_traits/composite_traits.hpp | 39 +++++-------------- tests/composite_traits_test.cpp | 4 -- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/include/boost/type_traits/composite_traits.hpp b/include/boost/type_traits/composite_traits.hpp index 3f1f828..4786863 100644 --- a/include/boost/type_traits/composite_traits.hpp +++ b/include/boost/type_traits/composite_traits.hpp @@ -280,7 +280,6 @@ template struct is_reference # pragma warning(disable: 4181) #endif // BOOST_MSVC - namespace detail { template struct is_reference_or_const_volatile @@ -298,42 +297,22 @@ namespace detail >::value)); }; - no_type non_array_is_reference_helper(...); - template - yes_type non_array_is_reference_helper(T&(*)()); + template struct wrap {}; + template T&(* is_reference_helper1(wrap) )(wrap); + char is_reference_helper1(...); - template - struct is_reference_helper - { - template - struct apply - { - typedef T (*pf_t)(); - static pf_t pf; - - BOOST_STATIC_CONSTANT( - bool, value = (1 == sizeof(::boost::detail::non_array_is_reference_helper(pf)))); - }; - }; - - template <> - struct is_reference_helper - { - template - struct apply - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - }; + template no_type is_reference_helper2(T&(*)(wrap)); + yes_type is_reference_helper2(...); } template struct is_reference { BOOST_STATIC_CONSTANT( - bool, value = ::boost::detail::is_reference_helper< - is_array::value - >::template apply::value); + bool, value = sizeof( + ::boost::detail::is_reference_helper2( + ::boost::detail::is_reference_helper1(::boost::detail::wrap()))) == 1 + ); }; template <> struct is_reference diff --git a/tests/composite_traits_test.cpp b/tests/composite_traits_test.cpp index 6c8463a..01dc843 100644 --- a/tests/composite_traits_test.cpp +++ b/tests/composite_traits_test.cpp @@ -94,9 +94,7 @@ int cpp_main(int argc, char* argv[]) value_test(true, boost::is_reference::value) value_test(true, boost::is_reference::value) value_test(false, boost::is_reference::value) -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC) value_test(false, boost::is_reference::value) -#endif value_test(false, boost::is_member_pointer::value) value_test(false, boost::is_member_pointer::value) @@ -133,9 +131,7 @@ int cpp_main(int argc, char* argv[]) value_test(false, boost::is_enum::value) //value_test(false, boost::is_enum::value) value_test(false, boost::is_enum::value) -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC) value_test(false, boost::is_enum::value) -#endif return check_result(argc, argv); }