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"
18 struct is_polymorphic_imp1
20 typedef typename remove_cv<T>::type ncvT;
21 struct d1 : public ncvT
24 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
29 struct d2 : public ncvT
34 // for some reason this messes up VC++ when T has virtual bases:
39 BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
43 struct is_polymorphic_imp2
45 BOOST_STATIC_CONSTANT(bool, value = false);
48 template <bool is_class>
49 struct is_polymorphic_selector
54 typedef is_polymorphic_imp2<T> type;
59 struct is_polymorphic_selector<true>
64 typedef is_polymorphic_imp1<T> type;
69 struct is_polymorphic_imp
71 typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
72 typedef typename selector::template rebind<T> binder;
73 typedef typename binder::type imp_type;
74 BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
79 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
83 #include "boost/type_traits/detail/bool_trait_undef.hpp"