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/is_class.hpp>
12 #include <boost/type_traits/remove_cv.hpp>
13 // should be the last #include
14 #include "boost/type_traits/detail/bool_trait_def.hpp"
15 #include <boost/detail/workaround.hpp>
21 struct is_polymorphic_imp1
23 # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
24 typedef char d1, (&d2)[2];
26 typedef typename remove_cv<T>::type ncvT;
27 struct d1 : public ncvT
30 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
35 struct d2 : public ncvT
39 # if !defined(BOOST_MSVC) && !defined(__ICL)
40 // for some reason this messes up VC++ when T has virtual bases,
41 // probably likewise for compilers that use the same ABI:
43 virtual void foo(unique*);
48 BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
52 struct is_polymorphic_imp2
54 BOOST_STATIC_CONSTANT(bool, value = false);
57 template <bool is_class>
58 struct is_polymorphic_selector
63 typedef is_polymorphic_imp2<T> type;
68 struct is_polymorphic_selector<true>
73 typedef is_polymorphic_imp1<T> type;
78 struct is_polymorphic_imp
80 typedef is_polymorphic_selector< ::boost::is_class<T>::value> selector;
81 typedef typename selector::template rebind<T> binder;
82 typedef typename binder::type imp_type;
83 BOOST_STATIC_CONSTANT(bool, value = imp_type::value);
88 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
92 #include "boost/type_traits/detail/bool_trait_undef.hpp"