1 // (C) Copyright John Maddock 2000.
2 // Use, modification and distribution are subject to the Boost Software License,
3 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt).
6 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
8 #ifndef BOOST_TT_IS_POLYMORPHIC_HPP
9 #define BOOST_TT_IS_POLYMORPHIC_HPP
11 #include <boost/type_traits/intrinsics.hpp>
12 #include <boost/type_traits/integral_constant.hpp>
13 #ifndef BOOST_IS_POLYMORPHIC
14 #include <boost/type_traits/is_class.hpp>
16 #include <boost/detail/workaround.hpp>
18 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700)
20 #pragma warning(disable:4250)
25 #ifndef BOOST_IS_POLYMORPHIC
30 struct is_polymorphic_imp1
32 # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
33 typedef char d1, (&d2)[2];
38 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
43 // keep some picky compilers happy:
45 d1& operator=(const d1&);
51 # if !defined(BOOST_MSVC) && !defined(__ICL)
52 // for some reason this messes up VC++ when T has virtual bases,
53 // probably likewise for compilers that use the same ABI:
55 virtual void unique_name_to_boost5487629(unique*);
59 // keep some picky compilers happy:
61 d2& operator=(const d2&);
64 BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
67 template <class T> struct is_polymorphic_imp1<T const> : public is_polymorphic_imp1<T>{};
68 template <class T> struct is_polymorphic_imp1<T const volatile> : public is_polymorphic_imp1<T>{};
69 template <class T> struct is_polymorphic_imp1<T volatile> : public is_polymorphic_imp1<T>{};
72 struct is_polymorphic_imp2
74 BOOST_STATIC_CONSTANT(bool, value = false);
77 template <bool is_class>
78 struct is_polymorphic_selector
83 typedef is_polymorphic_imp2<T> type;
88 struct is_polymorphic_selector<true>
93 typedef is_polymorphic_imp1<T> type;
98 struct is_polymorphic_imp
100 typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
101 typedef typename selector::template rebind<T> binder;
102 typedef typename binder::type imp_type;
103 BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
106 } // namespace detail
108 template <class T> struct is_polymorphic : public integral_constant<bool, ::boost::detail::is_polymorphic_imp<T>::value> {};
110 #else // BOOST_IS_POLYMORPHIC
112 template <class T> struct is_polymorphic : public integral_constant<bool, BOOST_IS_POLYMORPHIC(T)> {};
118 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700)