From 26fcfa4616b2a137129ee9d94970ac5ffb279e37 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 2 Feb 2002 23:23:42 +0000 Subject: [PATCH] Fixed is_reference::value for compilers without partial specialization. [SVN r12654] --- .../boost/type_traits/composite_traits.hpp | 75 +++++++++++++++---- 1 file changed, 61 insertions(+), 14 deletions(-) diff --git a/include/boost/type_traits/composite_traits.hpp b/include/boost/type_traits/composite_traits.hpp index 129fead..d7b4f69 100644 --- a/include/boost/type_traits/composite_traits.hpp +++ b/include/boost/type_traits/composite_traits.hpp @@ -65,6 +65,10 @@ template struct is_array { BOOST_STATIC_CONSTANT(bool, value = true); }; #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION namespace detail{ + + template + struct is_reference_or_const_volatile; + struct pointer_helper { pointer_helper(const volatile void*); @@ -152,7 +156,7 @@ public: (::boost::type_traits::ice_and< (1 == sizeof(detail::is_array_helper(&t, t))), ::boost::type_traits::ice_not< - ::boost::is_reference::value>::value, + ::boost::detail::is_reference_or_const_volatile::value>::value, ::boost::type_traits::ice_not< (1 == sizeof(detail::is_function_tester(t)))>::value >::value)); @@ -274,20 +278,63 @@ template struct is_reference # pragma warning(push) # pragma warning(disable: 4181) #endif // BOOST_MSVC -template struct is_reference -{ -private: - typedef T const volatile cv_t; -public: - BOOST_STATIC_CONSTANT(bool, value = - (::boost::type_traits::ice_or< - ::boost::type_traits::ice_not< - ::boost::is_const::value - >::value, - ::boost::type_traits::ice_not< - ::boost::is_volatile::value>::value - >::value)); + + +namespace detail +{ + template struct is_reference_or_const_volatile + { + private: + typedef T const volatile cv_t; + public: + BOOST_STATIC_CONSTANT(bool, value = + (::boost::type_traits::ice_or< + ::boost::type_traits::ice_not< + ::boost::is_const::value + >::value, + ::boost::type_traits::ice_not< + ::boost::is_volatile::value>::value + >::value)); + }; + + no_type non_array_is_reference_helper(...); + template + yes_type non_array_is_reference_helper(T&(*)()); + + 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 +struct is_reference +{ + BOOST_STATIC_CONSTANT( + bool, value = ::boost::detail::is_reference_helper< + is_array::value + >::template apply::value); }; + template <> struct is_reference { BOOST_STATIC_CONSTANT(bool, value = false);