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 )
26 #elif defined __GNUC__
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 X
: public virtual Derived
, public virtual Base
44 X
& operator=(const X
&);
47 struct Y
: public virtual Derived
51 Y
& operator=(const Y
&);
55 struct X
: Derived
, virtual Base
59 X
& operator=(const X
&);
66 Y
& operator=(const Y
&);
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
);
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>