Chris@16
|
1 // (C) Copyright Daniel Frey and Robert Ramey 2009.
|
Chris@16
|
2 // Use, modification and distribution are subject to the Boost Software License,
|
Chris@16
|
3 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
4 // http://www.boost.org/LICENSE_1_0.txt).
|
Chris@16
|
5 //
|
Chris@16
|
6 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
|
Chris@16
|
9 #define BOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/type_traits/is_base_of.hpp>
|
Chris@16
|
12 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
13 #include <boost/mpl/and.hpp>
|
Chris@16
|
14 #include <boost/mpl/not.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 // should be the last #include
|
Chris@16
|
17 #include <boost/type_traits/detail/bool_trait_def.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 namespace boost {
|
Chris@16
|
20 namespace detail {
|
Chris@16
|
21
|
Chris@16
|
22
|
Chris@16
|
23 #ifdef BOOST_MSVC
|
Chris@16
|
24 #pragma warning( push )
|
Chris@16
|
25 #pragma warning( disable : 4584 4250)
|
Chris@16
|
26 #elif defined(__GNUC__) && (__GNUC__ >= 4)
|
Chris@16
|
27 #pragma GCC system_header
|
Chris@16
|
28 #endif
|
Chris@16
|
29
|
Chris@16
|
30 template<typename Base, typename Derived, typename tag>
|
Chris@16
|
31 struct is_virtual_base_of_impl
|
Chris@16
|
32 {
|
Chris@16
|
33 BOOST_STATIC_CONSTANT(bool, value = false);
|
Chris@16
|
34 };
|
Chris@16
|
35
|
Chris@16
|
36 template<typename Base, typename Derived>
|
Chris@16
|
37 struct is_virtual_base_of_impl<Base, Derived, mpl::true_>
|
Chris@16
|
38 {
|
Chris@16
|
39 #ifdef __BORLANDC__
|
Chris@16
|
40 struct boost_type_traits_internal_struct_X : public virtual Derived, public virtual Base
|
Chris@16
|
41 {
|
Chris@16
|
42 boost_type_traits_internal_struct_X();
|
Chris@16
|
43 boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
Chris@16
|
44 boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
Chris@16
|
45 ~boost_type_traits_internal_struct_X()throw();
|
Chris@16
|
46 };
|
Chris@16
|
47 struct boost_type_traits_internal_struct_Y : public virtual Derived
|
Chris@16
|
48 {
|
Chris@16
|
49 boost_type_traits_internal_struct_Y();
|
Chris@16
|
50 boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
Chris@16
|
51 boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
Chris@16
|
52 ~boost_type_traits_internal_struct_Y()throw();
|
Chris@16
|
53 };
|
Chris@16
|
54 #else
|
Chris@16
|
55 struct boost_type_traits_internal_struct_X : public Derived, virtual Base
|
Chris@16
|
56 {
|
Chris@16
|
57 boost_type_traits_internal_struct_X();
|
Chris@16
|
58 boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
Chris@16
|
59 boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
Chris@16
|
60 ~boost_type_traits_internal_struct_X()throw();
|
Chris@16
|
61 };
|
Chris@16
|
62 struct boost_type_traits_internal_struct_Y : public Derived
|
Chris@16
|
63 {
|
Chris@16
|
64 boost_type_traits_internal_struct_Y();
|
Chris@16
|
65 boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
Chris@16
|
66 boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
Chris@16
|
67 ~boost_type_traits_internal_struct_Y()throw();
|
Chris@16
|
68 };
|
Chris@16
|
69 #endif
|
Chris@16
|
70 BOOST_STATIC_CONSTANT(bool, value = (sizeof(boost_type_traits_internal_struct_X)==sizeof(boost_type_traits_internal_struct_Y)));
|
Chris@16
|
71 };
|
Chris@16
|
72
|
Chris@16
|
73 template<typename Base, typename Derived>
|
Chris@16
|
74 struct is_virtual_base_of_impl2
|
Chris@16
|
75 {
|
Chris@16
|
76 typedef typename mpl::and_<is_base_of<Base, Derived>, mpl::not_<is_same<Base, Derived> > >::type tag_type;
|
Chris@16
|
77 typedef is_virtual_base_of_impl<Base, Derived, tag_type> imp;
|
Chris@16
|
78 BOOST_STATIC_CONSTANT(bool, value = imp::value);
|
Chris@16
|
79 };
|
Chris@16
|
80
|
Chris@16
|
81 #ifdef BOOST_MSVC
|
Chris@16
|
82 #pragma warning( pop )
|
Chris@16
|
83 #endif
|
Chris@16
|
84
|
Chris@16
|
85 } // namespace detail
|
Chris@16
|
86
|
Chris@16
|
87 BOOST_TT_AUX_BOOL_TRAIT_DEF2(
|
Chris@16
|
88 is_virtual_base_of
|
Chris@16
|
89 , Base
|
Chris@16
|
90 , Derived
|
Chris@16
|
91 , (::boost::detail::is_virtual_base_of_impl2<Base,Derived>::value)
|
Chris@16
|
92 )
|
Chris@16
|
93
|
Chris@16
|
94 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
Chris@16
|
95 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived,false)
|
Chris@16
|
96 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base,Derived&,false)
|
Chris@16
|
97 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived&,false)
|
Chris@16
|
98 #endif
|
Chris@16
|
99
|
Chris@16
|
100 } // namespace boost
|
Chris@16
|
101
|
Chris@16
|
102 #include <boost/type_traits/detail/bool_trait_undef.hpp>
|
Chris@16
|
103
|
Chris@16
|
104 #endif
|