]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/intrusive/detail/mpl.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / intrusive / detail / mpl.hpp
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2006-2014
4 // (C) Copyright Microsoft Corporation 2014
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 // See http://www.boost.org/libs/intrusive for documentation.
11 //
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP
15 #define BOOST_INTRUSIVE_DETAIL_MPL_HPP
16
17 #ifndef BOOST_CONFIG_HPP
18 # include <boost/config.hpp>
19 #endif
20
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 # pragma once
23 #endif
24
25 #include <boost/intrusive/detail/config_begin.hpp>
26 #include <boost/move/detail/type_traits.hpp>
27 #include <cstddef>
28
29 namespace boost {
30 namespace intrusive {
31 namespace detail {
32
33 using boost::move_detail::is_same;
34 using boost::move_detail::add_const;
35 using boost::move_detail::remove_const;
36 using boost::move_detail::remove_cv;
37 using boost::move_detail::remove_reference;
38 using boost::move_detail::add_reference;
39 using boost::move_detail::remove_pointer;
40 using boost::move_detail::add_pointer;
41 using boost::move_detail::true_type;
42 using boost::move_detail::false_type;
43 using boost::move_detail::enable_if_c;
44 using boost::move_detail::enable_if;
45 using boost::move_detail::disable_if_c;
46 using boost::move_detail::disable_if;
47 using boost::move_detail::is_convertible;
48 using boost::move_detail::if_c;
49 using boost::move_detail::if_;
50 using boost::move_detail::is_const;
51 using boost::move_detail::identity;
52 using boost::move_detail::alignment_of;
53 using boost::move_detail::is_empty;
54 using boost::move_detail::addressof;
55 using boost::move_detail::integral_constant;
56 using boost::move_detail::enable_if_convertible;
57 using boost::move_detail::disable_if_convertible;
58 using boost::move_detail::bool_;
59 using boost::move_detail::true_;
60 using boost::move_detail::false_;
61 using boost::move_detail::yes_type;
62 using boost::move_detail::no_type;
63 using boost::move_detail::apply;
64 using boost::move_detail::eval_if_c;
65 using boost::move_detail::eval_if;
66 using boost::move_detail::unvoid_ref;
67 using boost::move_detail::add_const_if_c;
68
69 template<std::size_t S>
70 struct ls_zeros
71 {
72 static const std::size_t value = (S & std::size_t(1)) ? 0 : (1 + ls_zeros<(S>>1u)>::value);
73 };
74
75 template<>
76 struct ls_zeros<0>
77 {
78 static const std::size_t value = 0;
79 };
80
81 template<>
82 struct ls_zeros<1>
83 {
84 static const std::size_t value = 0;
85 };
86
87 // Infrastructure for providing a default type for T::TNAME if absent.
88 #define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \
89 template <typename T> \
90 struct boost_intrusive_has_type_ ## TNAME \
91 { \
92 template <typename X> \
93 static char test(int, typename X::TNAME*); \
94 \
95 template <typename X> \
96 static int test(...); \
97 \
98 static const bool value = (1 == sizeof(test<T>(0, 0))); \
99 }; \
100 \
101 template <typename T, typename DefaultType> \
102 struct boost_intrusive_default_type_ ## TNAME \
103 { \
104 struct DefaultWrap { typedef DefaultType TNAME; }; \
105 \
106 typedef typename \
107 ::boost::intrusive::detail::if_c \
108 < boost_intrusive_has_type_ ## TNAME<T>::value \
109 , T, DefaultWrap>::type::TNAME type; \
110 }; \
111 //
112
113 #define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
114 typename INSTANTIATION_NS_PREFIX \
115 boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \
116 //
117
118 #define BOOST_INTRUSIVE_HAS_TYPE(INSTANTIATION_NS_PREFIX, T, TNAME) \
119 INSTANTIATION_NS_PREFIX \
120 boost_intrusive_has_type_ ## TNAME< T >::value \
121 //
122
123 #define BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(TNAME)\
124 template <typename T, typename DefaultType> \
125 struct boost_intrusive_eval_default_type_ ## TNAME \
126 { \
127 template <typename X> \
128 static char test(int, typename X::TNAME*); \
129 \
130 template <typename X> \
131 static int test(...); \
132 \
133 struct DefaultWrap \
134 { typedef typename DefaultType::type TNAME; }; \
135 \
136 static const bool value = (1 == sizeof(test<T>(0, 0))); \
137 \
138 typedef typename \
139 ::boost::intrusive::detail::eval_if_c \
140 < value \
141 , ::boost::intrusive::detail::identity<T> \
142 , ::boost::intrusive::detail::identity<DefaultWrap> \
143 >::type::TNAME type; \
144 }; \
145 //
146
147 #define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \
148 typename INSTANTIATION_NS_PREFIX \
149 boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \
150 //
151
152 #define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
153 template <class T>\
154 struct TRAITS_PREFIX##_bool\
155 {\
156 template<bool Add>\
157 struct two_or_three {yes_type _[2 + Add];};\
158 template <class U> static yes_type test(...);\
159 template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
160 static const std::size_t value = sizeof(test<T>(0));\
161 };\
162 \
163 template <class T>\
164 struct TRAITS_PREFIX##_bool_is_true\
165 {\
166 static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(yes_type)*2;\
167 };\
168 //
169
170 #define BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(TRAITS_NAME, FUNC_NAME) \
171 template <typename U, typename Signature> \
172 class TRAITS_NAME \
173 { \
174 private: \
175 template<Signature> struct helper;\
176 template<typename T> \
177 static ::boost::intrusive::detail::yes_type test(helper<&T::FUNC_NAME>*); \
178 template<typename T> static ::boost::intrusive::detail::no_type test(...); \
179 public: \
180 static const bool value = sizeof(test<U>(0)) == sizeof(::boost::intrusive::detail::yes_type); \
181 }; \
182 //
183
184 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME, FUNC_NAME) \
185 template <typename Type> \
186 struct TRAITS_NAME \
187 { \
188 struct BaseMixin \
189 { \
190 void FUNC_NAME(); \
191 }; \
192 struct Base : public Type, public BaseMixin { Base(); }; \
193 template <typename T, T t> class Helper{}; \
194 template <typename U> \
195 static ::boost::intrusive::detail::no_type test(U*, Helper<void (BaseMixin::*)(), &U::FUNC_NAME>* = 0); \
196 static ::boost::intrusive::detail::yes_type test(...); \
197 static const bool value = sizeof(::boost::intrusive::detail::yes_type) == sizeof(test((Base*)(0))); \
198 };\
199 //
200
201 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(TRAITS_NAME, FUNC_NAME) \
202 BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME##_ignore_signature, FUNC_NAME) \
203 \
204 template <typename Type, class> \
205 struct TRAITS_NAME \
206 : public TRAITS_NAME##_ignore_signature<Type> \
207 {};\
208 //
209
210 } //namespace detail
211 } //namespace intrusive
212 } //namespace boost
213
214 #include <boost/intrusive/detail/config_end.hpp>
215
216 #endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP