]> git.donarmstrong.com Git - rsem.git/blob - boost/type_traits/is_polymorphic.hpp
RSEM Source Codes
[rsem.git] / boost / type_traits / is_polymorphic.hpp
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).
5 //
6 //  See http://www.boost.org/libs/type_traits for most recent version including documentation.
7
8 #ifndef BOOST_TT_IS_POLYMORPHIC_HPP
9 #define BOOST_TT_IS_POLYMORPHIC_HPP
10
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>
15 #endif
16 // should be the last #include
17 #include <boost/type_traits/detail/bool_trait_def.hpp>
18 #include <boost/detail/workaround.hpp>
19
20 namespace boost{
21
22 #ifndef BOOST_IS_POLYMORPHIC
23
24 namespace detail{
25
26 template <class T>
27 struct is_polymorphic_imp1
28 {
29 # if BOOST_WORKAROUND(__MWERKS__, <= 0x2407) // CWPro7 should return false always.
30     typedef char d1, (&d2)[2];
31 # else 
32    typedef typename remove_cv<T>::type ncvT;
33    struct d1 : public ncvT
34    {
35       d1();
36 #  if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
37       ~d1()throw();
38 #  endif 
39       char padding[256];
40    private:
41       // keep some picky compilers happy:
42       d1(const d1&);
43       d1& operator=(const d1&);
44    };
45    struct d2 : public ncvT
46    {
47       d2();
48       virtual ~d2()throw();
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:
52       struct unique{};
53       virtual void unique_name_to_boost5487629(unique*);
54 #  endif
55       char padding[256];
56    private:
57       // keep some picky compilers happy:
58       d2(const d2&);
59       d2& operator=(const d2&);
60    };
61 # endif 
62    BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
63 };
64
65 template <class T>
66 struct is_polymorphic_imp2
67 {
68    BOOST_STATIC_CONSTANT(bool, value = false);
69 };
70
71 template <bool is_class>
72 struct is_polymorphic_selector
73 {
74    template <class T>
75    struct rebind
76    {
77       typedef is_polymorphic_imp2<T> type;
78    };
79 };
80
81 template <>
82 struct is_polymorphic_selector<true>
83 {
84    template <class T>
85    struct rebind
86    {
87       typedef is_polymorphic_imp1<T> type;
88    };
89 };
90
91 template <class T>
92 struct is_polymorphic_imp
93 {
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);
98 };
99
100 } // namespace detail
101
102 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
103
104 #else // BOOST_IS_POLYMORPHIC
105
106 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,BOOST_IS_POLYMORPHIC(T))
107
108 #endif
109
110 } // namespace boost
111
112 #include <boost/type_traits/detail/bool_trait_undef.hpp>
113
114 #endif