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