Fixed is_polymorphic for cv-qualified class types

[SVN r16339]
This commit is contained in:
John Maddock
2002-11-20 12:08:15 +00:00
parent 814e55ff5e
commit 6e4f49afc6
2 changed files with 17 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#define BOOST_TT_IS_POLYMORPHIC_HPP
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/remove_cv.hpp>
// should be the last #include
#include "boost/type_traits/detail/bool_trait_def.hpp"
@ -16,13 +17,14 @@ namespace detail{
template <class T>
struct is_polymorphic_imp1
{
struct d1 : public T
typedef remove_cv<T>::type ncvT;
struct d1 : public ncvT
{
d1();
~d1()throw();
char padding[256];
};
struct d2 : public T
struct d2 : public ncvT
{
d2();
virtual ~d2()throw();

View File

@ -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<test_abc1, const test_abc1>::value)
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<void,float>::value), false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const UDT>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<volatile empty_UDT>::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const VB>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const volatile VD>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const test_abc1>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<volatile test_abc2>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::exception>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::bad_alloc>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::runtime_error>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::out_of_range>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<const std::range_error>::value, true);
TT_TEST_END