Need to use __is_polymorphic intrinsic with msvc

when final is supported.
Also improve tests.
This commit is contained in:
jzmaddock
2015-07-07 12:30:28 +01:00
parent ebf5ae3b76
commit 04a8a9ecc2
3 changed files with 18 additions and 7 deletions

View File

@@ -112,8 +112,6 @@
# define BOOST_IS_CLASS(T) __is_class(T)
# define BOOST_IS_CONVERTIBLE(T,U) ((__is_convertible_to(T,U) || (is_same<T,U>::value && !is_function<U>::value)) && !__is_abstract(U))
# define BOOST_IS_ENUM(T) __is_enum(T)
// This one doesn't quite always do the right thing:
// # define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
// This one fails if the default alignment has been changed with /Zp:
// # define BOOST_ALIGNMENT_OF(T) __alignof(T)
@@ -121,6 +119,11 @@
# define BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) ((__has_trivial_move_constructor(T) || boost::is_pod<T>::value) && ! ::boost::is_volatile<T>::value && ! ::boost::is_reference<T>::value)
# define BOOST_HAS_TRIVIAL_MOVE_ASSIGN(T) ((__has_trivial_move_assign(T) || boost::is_pod<T>::value) && ! ::boost::is_const<T>::value && !::boost::is_volatile<T>::value && ! ::boost::is_reference<T>::value)
# endif
#ifndef BOOST_NO_CXX11_FINAL
// This one doesn't quite always do the right thing on older VC++ versions
// we really need it when the final keyword is supporyted though:
# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
#endif
#if _MSC_FULL_VER >= 180020827
# define BOOST_IS_NOTHROW_MOVE_ASSIGN(T) (__is_nothrow_assignable(T&, T&&))
# define BOOST_IS_NOTHROW_MOVE_CONSTRUCT(T) (__is_nothrow_constructible(T, T&&))

View File

@@ -82,6 +82,11 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<IDispatch>::value, true);
// this test was added to check for bug reported on 21 May 2003:
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<poly_bug>::value, true);
#ifndef BOOST_NO_CXX11_FINAL
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic < final_UDT >::value, false);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_polymorphic<polymorphic_derived_final>::value, true);
#endif
TT_TEST_END

View File

@@ -265,11 +265,6 @@ struct nothrow_construct_UDT
{ return true; }
};
#ifndef BOOST_NO_CXX11_FINAL
struct final_UDT final
{};
#endif
class Base { };
class Derived : public Base { };
@@ -370,6 +365,14 @@ struct polymorphic_derived2 : public polymorphic_base
virtual void method();
};
#ifndef BOOST_NO_CXX11_FINAL
struct final_UDT final
{};
struct polymorphic_derived_final final : public polymorphic_derived2
{};
#endif
struct virtual_inherit1 : public virtual Base { };
struct virtual_inherit2 : public virtual_inherit1 { };
struct virtual_inherit3 : private virtual Base {};