From 6e4f49afc6e7296906b8c001035f8ad9d347637c Mon Sep 17 00:00:00 2001 From: John Maddock Date: Wed, 20 Nov 2002 12:08:15 +0000 Subject: [PATCH] Fixed is_polymorphic for cv-qualified class types [SVN r16339] --- include/boost/type_traits/is_polymorphic.hpp | 6 ++++-- test/tricky_partial_specialization_test.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/boost/type_traits/is_polymorphic.hpp b/include/boost/type_traits/is_polymorphic.hpp index ee73711..ea0aeb8 100644 --- a/include/boost/type_traits/is_polymorphic.hpp +++ b/include/boost/type_traits/is_polymorphic.hpp @@ -7,6 +7,7 @@ #define BOOST_TT_IS_POLYMORPHIC_HPP #include +#include // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -16,13 +17,14 @@ namespace detail{ template struct is_polymorphic_imp1 { - struct d1 : public T + typedef remove_cv::type ncvT; + struct d1 : public ncvT { d1(); ~d1()throw(); char padding[256]; }; - struct d2 : public T + struct d2 : public ncvT { d2(); virtual ~d2()throw(); diff --git a/test/tricky_partial_specialization_test.cpp b/test/tricky_partial_specialization_test.cpp index fd48351..746f173 100644 --- a/test/tricky_partial_specialization_test.cpp +++ b/test/tricky_partial_specialization_test.cpp @@ -13,6 +13,7 @@ #include TYPE_TRAITS(is_base_and_derived) #include TYPE_COMPARE(is_same) #include TYPE_COMPARE(is_convertible) +#include TYPE_TRAITS(is_polymorphic) // // VC++ emits an awful lot of warnings unless we define these: @@ -59,6 +60,18 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same::value) BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic::value, true); + TT_TEST_END