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 #ifndef BOOST_IS_POLYMORPHIC
13 #include <boost/type_traits/is_class.hpp>
14 #include <boost/type_traits/remove_cv.hpp>
16 // should be the last #include
17 #include <boost/type_traits/detail/bool_trait_def.hpp>
18 #include <boost/detail/workaround.hpp>
22 #ifndef BOOST_IS_POLYMORPHIC
27 struct is_polymorphic_imp1
29 # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
30 typedef char d1, (&d2)[2];
32 typedef typename remove_cv<T>::type ncvT;
33 struct d1 : public ncvT
36 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
41 // keep some picky compilers happy:
43 d1& operator=(const d1&);
45 struct d2 : public ncvT
49 # if !defined(BOOST_MSVC) && !defined(__ICL)
50 // for some reason this messes up VC++ when T has virtual bases,
51 // probably likewise for compilers that use the same ABI:
53 virtual void unique_name_to_boost5487629(unique*);
57 // keep some picky compilers happy:
59 d2& operator=(const d2&);
62 BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
66 struct is_polymorphic_imp2
68 BOOST_STATIC_CONSTANT(bool, value = false);
71 template <bool is_class>
72 struct is_polymorphic_selector
77 typedef is_polymorphic_imp2<T> type;
82 struct is_polymorphic_selector<true>
87 typedef is_polymorphic_imp1<T> type;
92 struct is_polymorphic_imp
94 typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
95 typedef typename selector::template rebind<T> binder;
96 typedef typename binder::type imp_type;
97 BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
100 } // namespace detail
102 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
104 #else // BOOST_IS_POLYMORPHIC
106 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,BOOST_IS_POLYMORPHIC(T))
112 #include <boost/type_traits/detail/bool_trait_undef.hpp>