]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_polymorphic.hpp
update boost to pre-1.30.0
[lyx.git] / boost / boost / type_traits / is_polymorphic.hpp
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.
5
6 #ifndef BOOST_TT_IS_POLYMORPHIC_HPP
7 #define BOOST_TT_IS_POLYMORPHIC_HPP
8
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
14 namespace boost{
15 namespace detail{
16
17 template <class T>
18 struct is_polymorphic_imp1
19 {
20    typedef typename remove_cv<T>::type ncvT;
21    struct d1 : public ncvT
22    {
23       d1();
24 # if !defined(__GNUC__) // this raises warnings with some classes, and buys nothing with GCC
25       ~d1()throw();
26 # endif 
27       char padding[256];
28    };
29    struct d2 : public ncvT
30    {
31       d2();
32       virtual ~d2()throw();
33 #ifndef BOOST_MSVC
34       // for some reason this messes up VC++ when T has virtual bases:
35       virtual void foo();
36 #endif
37       char padding[256];
38    };
39    BOOST_STATIC_CONSTANT(bool, value = (sizeof(d2) == sizeof(d1)));
40 };
41
42 template <class T>
43 struct is_polymorphic_imp2
44 {
45    BOOST_STATIC_CONSTANT(bool, value = false);
46 };
47
48 template <bool is_class>
49 struct is_polymorphic_selector
50 {
51    template <class T>
52    struct rebind
53    {
54       typedef is_polymorphic_imp2<T> type;
55    };
56 };
57
58 template <>
59 struct is_polymorphic_selector<true>
60 {
61    template <class T>
62    struct rebind
63    {
64       typedef is_polymorphic_imp1<T> type;
65    };
66 };
67
68 template <class T>
69 struct is_polymorphic_imp
70 {
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);
75 };
76
77 } // namespace detail
78
79 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_polymorphic,T,::boost::detail::is_polymorphic_imp<T>::value)
80
81 } // namespace boost
82
83 #include "boost/type_traits/detail/bool_trait_undef.hpp"
84
85 #endif