fix doc example typo
[boost.git] / boost / type_traits / is_virtual_base_of.hpp
blobe3dd441940fb6ddb4bcdb4d3c7fb4d8d4fcdd1b4
1 // (C) Copyright Daniel Frey and Robert Ramey 2009.
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.
8 #ifndef BOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
9 #define BOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
11 #include <boost/type_traits/is_base_of.hpp>
12 #include <boost/type_traits/is_same.hpp>
13 #include <boost/mpl/and.hpp>
14 #include <boost/mpl/not.hpp>
16 // should be the last #include
17 #include <boost/type_traits/detail/bool_trait_def.hpp>
19 namespace boost {
20 namespace detail {
23 #ifdef BOOST_MSVC
24 #pragma warning( push )
25 #pragma warning( disable : 4584 )
26 #elif defined __GNUC__
27 #pragma GCC system_header
28 #endif
30 template<typename Base, typename Derived, typename tag>
31 struct is_virtual_base_of_impl
33 BOOST_STATIC_CONSTANT(bool, value = false);
36 template<typename Base, typename Derived>
37 struct is_virtual_base_of_impl<Base, Derived, mpl::true_>
39 #ifdef __BORLANDC__
40 struct X : public virtual Derived, public virtual Base
42 X();
43 X(const X&);
44 X& operator=(const X&);
45 ~X();
47 struct Y : public virtual Derived
49 Y();
50 Y(const Y&);
51 Y& operator=(const Y&);
52 ~Y();
54 #else
55 struct X : Derived, virtual Base
57 X();
58 X(const X&);
59 X& operator=(const X&);
60 ~X();
62 struct Y : Derived
64 Y();
65 Y(const Y&);
66 Y& operator=(const Y&);
67 ~Y();
69 #endif
70 BOOST_STATIC_CONSTANT(bool, value = (sizeof(X)==sizeof(Y)));
73 template<typename Base, typename Derived>
74 struct is_virtual_base_of_impl2
76 typedef typename mpl::and_<is_base_of<Base, Derived>, mpl::not_<is_same<Base, Derived> > >::type tag_type;
77 typedef is_virtual_base_of_impl<Base, Derived, tag_type> imp;
78 BOOST_STATIC_CONSTANT(bool, value = imp::value);
81 #ifdef BOOST_MSVC
82 #pragma warning( pop )
83 #endif
85 } // namespace detail
87 BOOST_TT_AUX_BOOL_TRAIT_DEF2(
88 is_virtual_base_of
89 , Base
90 , Derived
91 , (::boost::detail::is_virtual_base_of_impl2<Base,Derived>::value)
94 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
95 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived,false)
96 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base,Derived&,false)
97 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived&,false)
98 #endif
100 } // namespace boost
102 #include <boost/type_traits/detail/bool_trait_undef.hpp>
104 #endif