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).
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>
24 #pragma warning( push )
25 #pragma warning( disable : 4584 4250)
26 #elif defined(__GNUC__) && (__GNUC__ >= 4)
27 #pragma GCC system_header
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_>
40 struct boost_type_traits_internal_struct_X : public virtual Derived, public virtual Base
42 boost_type_traits_internal_struct_X();
43 boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
44 boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
45 ~boost_type_traits_internal_struct_X()throw();
47 struct boost_type_traits_internal_struct_Y : public virtual Derived
49 boost_type_traits_internal_struct_Y();
50 boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
51 boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
52 ~boost_type_traits_internal_struct_Y()throw();
55 struct boost_type_traits_internal_struct_X : public Derived, virtual Base
57 boost_type_traits_internal_struct_X();
58 boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
59 boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
60 ~boost_type_traits_internal_struct_X()throw();
62 struct boost_type_traits_internal_struct_Y : public Derived
64 boost_type_traits_internal_struct_Y();
65 boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
66 boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
67 ~boost_type_traits_internal_struct_Y()throw();
70 BOOST_STATIC_CONSTANT(bool, value = (sizeof(boost_type_traits_internal_struct_X)==sizeof(boost_type_traits_internal_struct_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);
82 #pragma warning( pop )
87 BOOST_TT_AUX_BOOL_TRAIT_DEF2(
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)
102 #include <boost/type_traits/detail/bool_trait_undef.hpp>