Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/detail/mpl.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 ///////////////////////////////////////////////////////////////////////////// | |
2 // | |
3 // (C) Copyright Ion Gaztanaga 2006-2013 | |
4 // | |
5 // Distributed under the Boost Software License, Version 1.0. | |
6 // (See accompanying file LICENSE_1_0.txt or copy at | |
7 // http://www.boost.org/LICENSE_1_0.txt) | |
8 // | |
9 // See http://www.boost.org/libs/intrusive for documentation. | |
10 // | |
11 ///////////////////////////////////////////////////////////////////////////// | |
12 | |
13 #ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP | |
14 #define BOOST_INTRUSIVE_DETAIL_MPL_HPP | |
15 | |
16 #include <boost/intrusive/detail/config_begin.hpp> | |
17 #include <cstddef> | |
18 | |
19 namespace boost { | |
20 namespace intrusive { | |
21 namespace detail { | |
22 | |
23 typedef char one; | |
24 struct two {one _[2];}; | |
25 | |
26 template< bool C_ > | |
27 struct bool_ | |
28 { | |
29 static const bool value = C_; | |
30 }; | |
31 | |
32 typedef bool_<true> true_; | |
33 typedef bool_<false> false_; | |
34 | |
35 typedef true_ true_type; | |
36 typedef false_ false_type; | |
37 | |
38 typedef char yes_type; | |
39 struct no_type | |
40 { | |
41 char padding[8]; | |
42 }; | |
43 | |
44 template <bool B, class T = void> | |
45 struct enable_if_c { | |
46 typedef T type; | |
47 }; | |
48 | |
49 template <class T> | |
50 struct enable_if_c<false, T> {}; | |
51 | |
52 template <class Cond, class T = void> | |
53 struct enable_if : public enable_if_c<Cond::value, T>{}; | |
54 | |
55 template<class F, class Param> | |
56 struct apply | |
57 { | |
58 typedef typename F::template apply<Param>::type type; | |
59 }; | |
60 | |
61 template <class T, class U> | |
62 class is_convertible | |
63 { | |
64 typedef char true_t; | |
65 class false_t { char dummy[2]; }; | |
66 static true_t dispatch(U); | |
67 static false_t dispatch(...); | |
68 static const T &trigger(); | |
69 public: | |
70 static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); | |
71 }; | |
72 | |
73 template< | |
74 bool C | |
75 , typename T1 | |
76 , typename T2 | |
77 > | |
78 struct if_c | |
79 { | |
80 typedef T1 type; | |
81 }; | |
82 | |
83 template< | |
84 typename T1 | |
85 , typename T2 | |
86 > | |
87 struct if_c<false,T1,T2> | |
88 { | |
89 typedef T2 type; | |
90 }; | |
91 | |
92 template< | |
93 typename C | |
94 , typename T1 | |
95 , typename T2 | |
96 > | |
97 struct if_ | |
98 { | |
99 typedef typename if_c<0 != C::value, T1, T2>::type type; | |
100 }; | |
101 | |
102 template< | |
103 bool C | |
104 , typename F1 | |
105 , typename F2 | |
106 > | |
107 struct eval_if_c | |
108 : if_c<C,F1,F2>::type | |
109 {}; | |
110 | |
111 template< | |
112 typename C | |
113 , typename T1 | |
114 , typename T2 | |
115 > | |
116 struct eval_if | |
117 : if_<C,T1,T2>::type | |
118 {}; | |
119 | |
120 // identity is an extension: it is not part of the standard. | |
121 template <class T> | |
122 struct identity | |
123 { | |
124 typedef T type; | |
125 }; | |
126 | |
127 #if defined(BOOST_MSVC) || defined(__BORLANDC_) | |
128 #define BOOST_INTRUSIVE_TT_DECL __cdecl | |
129 #else | |
130 #define BOOST_INTRUSIVE_TT_DECL | |
131 #endif | |
132 | |
133 #if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(UNDER_CE) | |
134 #define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
135 #endif | |
136 | |
137 template <typename T> | |
138 struct is_unary_or_binary_function_impl | |
139 { static const bool value = false; }; | |
140 | |
141 // see boost ticket #4094 | |
142 // avoid duplicate definitions of is_unary_or_binary_function_impl | |
143 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
144 | |
145 template <typename R> | |
146 struct is_unary_or_binary_function_impl<R (*)()> | |
147 { static const bool value = true; }; | |
148 | |
149 template <typename R> | |
150 struct is_unary_or_binary_function_impl<R (*)(...)> | |
151 { static const bool value = true; }; | |
152 | |
153 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
154 | |
155 template <typename R> | |
156 struct is_unary_or_binary_function_impl<R (__stdcall*)()> | |
157 { static const bool value = true; }; | |
158 | |
159 #ifndef _MANAGED | |
160 | |
161 template <typename R> | |
162 struct is_unary_or_binary_function_impl<R (__fastcall*)()> | |
163 { static const bool value = true; }; | |
164 | |
165 #endif | |
166 | |
167 template <typename R> | |
168 struct is_unary_or_binary_function_impl<R (__cdecl*)()> | |
169 { static const bool value = true; }; | |
170 | |
171 template <typename R> | |
172 struct is_unary_or_binary_function_impl<R (__cdecl*)(...)> | |
173 { static const bool value = true; }; | |
174 | |
175 #endif | |
176 | |
177 // see boost ticket #4094 | |
178 // avoid duplicate definitions of is_unary_or_binary_function_impl | |
179 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
180 | |
181 template <typename R, class T0> | |
182 struct is_unary_or_binary_function_impl<R (*)(T0)> | |
183 { static const bool value = true; }; | |
184 | |
185 template <typename R, class T0> | |
186 struct is_unary_or_binary_function_impl<R (*)(T0...)> | |
187 { static const bool value = true; }; | |
188 | |
189 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
190 | |
191 template <typename R, class T0> | |
192 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)> | |
193 { static const bool value = true; }; | |
194 | |
195 #ifndef _MANAGED | |
196 | |
197 template <typename R, class T0> | |
198 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)> | |
199 { static const bool value = true; }; | |
200 | |
201 #endif | |
202 | |
203 template <typename R, class T0> | |
204 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)> | |
205 { static const bool value = true; }; | |
206 | |
207 template <typename R, class T0> | |
208 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)> | |
209 { static const bool value = true; }; | |
210 | |
211 #endif | |
212 | |
213 // see boost ticket #4094 | |
214 // avoid duplicate definitions of is_unary_or_binary_function_impl | |
215 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
216 | |
217 template <typename R, class T0, class T1> | |
218 struct is_unary_or_binary_function_impl<R (*)(T0, T1)> | |
219 { static const bool value = true; }; | |
220 | |
221 template <typename R, class T0, class T1> | |
222 struct is_unary_or_binary_function_impl<R (*)(T0, T1...)> | |
223 { static const bool value = true; }; | |
224 | |
225 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS | |
226 | |
227 template <typename R, class T0, class T1> | |
228 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)> | |
229 { static const bool value = true; }; | |
230 | |
231 #ifndef _MANAGED | |
232 | |
233 template <typename R, class T0, class T1> | |
234 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)> | |
235 { static const bool value = true; }; | |
236 | |
237 #endif | |
238 | |
239 template <typename R, class T0, class T1> | |
240 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)> | |
241 { static const bool value = true; }; | |
242 | |
243 template <typename R, class T0, class T1> | |
244 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)> | |
245 { static const bool value = true; }; | |
246 #endif | |
247 | |
248 template <typename T> | |
249 struct is_unary_or_binary_function_impl<T&> | |
250 { static const bool value = false; }; | |
251 | |
252 template<typename T> | |
253 struct is_unary_or_binary_function | |
254 { static const bool value = is_unary_or_binary_function_impl<T>::value; }; | |
255 | |
256 //boost::alignment_of yields to 10K lines of preprocessed code, so we | |
257 //need an alternative | |
258 template <typename T> struct alignment_of; | |
259 | |
260 template <typename T> | |
261 struct alignment_of_hack | |
262 { | |
263 char c; | |
264 T t; | |
265 alignment_of_hack(); | |
266 }; | |
267 | |
268 template <unsigned A, unsigned S> | |
269 struct alignment_logic | |
270 { | |
271 static const std::size_t value = A < S ? A : S; | |
272 }; | |
273 | |
274 template< typename T > | |
275 struct alignment_of | |
276 { | |
277 static const std::size_t value = alignment_logic | |
278 < sizeof(alignment_of_hack<T>) - sizeof(T) | |
279 , sizeof(T) | |
280 >::value; | |
281 }; | |
282 | |
283 template <typename T, typename U> | |
284 struct is_same | |
285 { | |
286 static const bool value = false; | |
287 }; | |
288 | |
289 template <typename T> | |
290 struct is_same<T, T> | |
291 { | |
292 static const bool value = true; | |
293 }; | |
294 | |
295 template<typename T> | |
296 struct add_const | |
297 { typedef const T type; }; | |
298 | |
299 template<typename T> | |
300 struct remove_const | |
301 { typedef T type; }; | |
302 | |
303 template<typename T> | |
304 struct remove_const<const T> | |
305 { typedef T type; }; | |
306 | |
307 template<typename T> | |
308 struct remove_cv | |
309 { typedef T type; }; | |
310 | |
311 template<typename T> | |
312 struct remove_cv<const T> | |
313 { typedef T type; }; | |
314 | |
315 template<typename T> | |
316 struct remove_cv<const volatile T> | |
317 { typedef T type; }; | |
318 | |
319 template<typename T> | |
320 struct remove_cv<volatile T> | |
321 { typedef T type; }; | |
322 | |
323 template<class T> | |
324 struct remove_reference | |
325 { | |
326 typedef T type; | |
327 }; | |
328 | |
329 template<class T> | |
330 struct remove_reference<T&> | |
331 { | |
332 typedef T type; | |
333 }; | |
334 | |
335 template<class Class> | |
336 class is_empty_class | |
337 { | |
338 template <typename T> | |
339 struct empty_helper_t1 : public T | |
340 { | |
341 empty_helper_t1(); | |
342 int i[256]; | |
343 }; | |
344 | |
345 struct empty_helper_t2 | |
346 { int i[256]; }; | |
347 | |
348 public: | |
349 static const bool value = sizeof(empty_helper_t1<Class>) == sizeof(empty_helper_t2); | |
350 }; | |
351 | |
352 template<std::size_t S> | |
353 struct ls_zeros | |
354 { | |
355 static const std::size_t value = (S & std::size_t(1)) ? 0 : (1 + ls_zeros<(S>>1u)>::value); | |
356 }; | |
357 | |
358 template<> | |
359 struct ls_zeros<0> | |
360 { | |
361 static const std::size_t value = 0; | |
362 }; | |
363 | |
364 template<> | |
365 struct ls_zeros<1> | |
366 { | |
367 static const std::size_t value = 0; | |
368 }; | |
369 | |
370 } //namespace detail | |
371 } //namespace intrusive | |
372 } //namespace boost | |
373 | |
374 #include <boost/intrusive/detail/config_end.hpp> | |
375 | |
376 #endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP |