1 // (C) Copyright John Maddock 2000. Permission to copy, use, modify, sell and
2 // distribute this software is granted provided this copyright notice appears
3 // in all copies. This software is provided "as is" without express or implied
4 // warranty, and with no claim as to its suitability for any purpose.
6 #ifndef BOOST_TT_IS_POLYMORPHIC_HPP
7 #define BOOST_TT_IS_POLYMORPHIC_HPP
9 #include <boost/type_traits/is_class.hpp>
10 #include <boost/type_traits/remove_cv.hpp>
11 // should be the last #include
12 #include "boost/type_traits/detail/bool_trait_def.hpp"
13 #include <boost/detail/workaround.hpp>
19 struct is_polymorphic_imp1
21 # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
22 typedef char d1, (&d2)[2];
24 typedef typename remove_cv<T>::type ncvT;
25 struct d1 : public ncvT
28 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
33 struct d2 : public ncvT
38 // for some reason this messes up VC++ when T has virtual bases:
44 BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
48 struct is_polymorphic_imp2
50 BOOST_STATIC_CONSTANT(bool, value = false);
53 template <bool is_class>
54 struct is_polymorphic_selector
59 typedef is_polymorphic_imp2<T> type;
64 struct is_polymorphic_selector<true>
69 typedef is_polymorphic_imp1<T> type;
74 struct is_polymorphic_imp
76 typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
77 typedef typename selector::template rebind<T> binder;
78 typedef typename binder::type imp_type;
79 BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
84 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
88 #include "boost/type_traits/detail/bool_trait_undef.hpp"