blob: 21c3f25ba24613abae7d3e7ecb8f7a979a4e5245 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// (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.
7
Jeff Thompson3d613fd2013-10-15 15:39:04 -07008#ifndef NDNBOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
9#define NDNBOOST_TT_IS_VIRTUAL_BASE_OF_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070010
11#include <ndnboost/type_traits/is_base_of.hpp>
12#include <ndnboost/type_traits/is_same.hpp>
13#include <ndnboost/mpl/and.hpp>
14#include <ndnboost/mpl/not.hpp>
15
16// should be the last #include
17#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
18
19namespace ndnboost {
20namespace detail {
21
22
Jeff Thompson3d613fd2013-10-15 15:39:04 -070023#ifdef NDNBOOST_MSVC
Jeff Thompsona28eed82013-08-22 16:21:10 -070024#pragma warning( push )
25#pragma warning( disable : 4584 4250)
26#elif defined(__GNUC__) && (__GNUC__ >= 4)
27#pragma GCC system_header
28#endif
29
30template<typename Base, typename Derived, typename tag>
31struct is_virtual_base_of_impl
32{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070033 NDNBOOST_STATIC_CONSTANT(bool, value = false);
Jeff Thompsona28eed82013-08-22 16:21:10 -070034};
35
36template<typename Base, typename Derived>
37struct is_virtual_base_of_impl<Base, Derived, mpl::true_>
38{
39#ifdef __BORLANDC__
40 struct boost_type_traits_internal_struct_X : public virtual Derived, public virtual Base
41 {
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();
46 };
47 struct boost_type_traits_internal_struct_Y : public virtual Derived
48 {
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();
53 };
54#else
55 struct boost_type_traits_internal_struct_X : public Derived, virtual Base
56 {
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();
61 };
62 struct boost_type_traits_internal_struct_Y : public Derived
63 {
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();
68 };
69#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070070 NDNBOOST_STATIC_CONSTANT(bool, value = (sizeof(boost_type_traits_internal_struct_X)==sizeof(boost_type_traits_internal_struct_Y)));
Jeff Thompsona28eed82013-08-22 16:21:10 -070071};
72
73template<typename Base, typename Derived>
74struct is_virtual_base_of_impl2
75{
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;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070078 NDNBOOST_STATIC_CONSTANT(bool, value = imp::value);
Jeff Thompsona28eed82013-08-22 16:21:10 -070079};
80
Jeff Thompson3d613fd2013-10-15 15:39:04 -070081#ifdef NDNBOOST_MSVC
Jeff Thompsona28eed82013-08-22 16:21:10 -070082#pragma warning( pop )
83#endif
84
85} // namespace detail
86
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2(
Jeff Thompsona28eed82013-08-22 16:21:10 -070088 is_virtual_base_of
89 , Base
90 , Derived
91 , (::ndnboost::detail::is_virtual_base_of_impl2<Base,Derived>::value)
92)
93
Jeff Thompson3d613fd2013-10-15 15:39:04 -070094#ifndef NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
95NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived,false)
96NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base,Derived&,false)
97NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(typename Base,typename Derived,is_virtual_base_of,Base&,Derived&,false)
Jeff Thompsona28eed82013-08-22 16:21:10 -070098#endif
99
100} // namespace ndnboost
101
102#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
103
104#endif