]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/detail/indirect_traits.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
a35b7cb86e57942b8f5a513ebd47698d1d759d99
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / detail / indirect_traits.hpp
1 // Copyright David Abrahams 2002.\r
2 // Distributed under the Boost Software License, Version 1.0. (See\r
3 // accompanying file LICENSE_1_0.txt or copy at\r
4 // http://www.boost.org/LICENSE_1_0.txt)\r
5 #ifndef INDIRECT_TRAITS_DWA2002131_HPP\r
6 # define INDIRECT_TRAITS_DWA2002131_HPP\r
7 # include <boost/type_traits/is_function.hpp>\r
8 # include <boost/type_traits/is_reference.hpp>\r
9 # include <boost/type_traits/is_pointer.hpp>\r
10 # include <boost/type_traits/is_class.hpp>\r
11 # include <boost/type_traits/is_const.hpp>\r
12 # include <boost/type_traits/is_volatile.hpp>\r
13 # include <boost/type_traits/is_member_function_pointer.hpp>\r
14 # include <boost/type_traits/is_member_pointer.hpp>\r
15 # include <boost/type_traits/remove_cv.hpp>\r
16 # include <boost/type_traits/remove_reference.hpp>\r
17 # include <boost/type_traits/remove_pointer.hpp>\r
18 \r
19 # include <boost/type_traits/detail/ice_and.hpp>\r
20 # include <boost/detail/workaround.hpp>\r
21 \r
22 # include <boost/mpl/eval_if.hpp>\r
23 # include <boost/mpl/if.hpp>\r
24 # include <boost/mpl/bool.hpp>\r
25 # include <boost/mpl/and.hpp>\r
26 # include <boost/mpl/not.hpp>\r
27 # include <boost/mpl/aux_/lambda_support.hpp>\r
28 \r
29 #  ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
30 #   include <boost/detail/is_function_ref_tester.hpp>\r
31 #  endif \r
32 \r
33 namespace boost { namespace detail {\r
34 \r
35 namespace indirect_traits {\r
36 \r
37 #  ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION\r
38 template <class T>\r
39 struct is_reference_to_const : mpl::false_\r
40 {\r
41 };\r
42 \r
43 template <class T>\r
44 struct is_reference_to_const<T const&> : mpl::true_\r
45 {\r
46 };\r
47 \r
48 #   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround\r
49 template<class T>\r
50 struct is_reference_to_const<T const volatile&> : mpl::true_\r
51 {\r
52 };\r
53 #   endif \r
54 \r
55 template <class T>\r
56 struct is_reference_to_function : mpl::false_\r
57 {\r
58 };\r
59 \r
60 template <class T>\r
61 struct is_reference_to_function<T&> : is_function<T>\r
62 {\r
63 };\r
64 \r
65 template <class T>\r
66 struct is_pointer_to_function : mpl::false_\r
67 {\r
68 };\r
69 \r
70 // There's no such thing as a pointer-to-cv-function, so we don't need\r
71 // specializations for those\r
72 template <class T>\r
73 struct is_pointer_to_function<T*> : is_function<T>\r
74 {\r
75 };\r
76 \r
77 template <class T>\r
78 struct is_reference_to_member_function_pointer_impl : mpl::false_\r
79 {\r
80 };\r
81 \r
82 template <class T>\r
83 struct is_reference_to_member_function_pointer_impl<T&>\r
84     : is_member_function_pointer<typename remove_cv<T>::type>\r
85 {\r
86 };\r
87 \r
88 \r
89 template <class T>\r
90 struct is_reference_to_member_function_pointer\r
91     : is_reference_to_member_function_pointer_impl<T>\r
92 {\r
93     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))\r
94 };\r
95 \r
96 template <class T>\r
97 struct is_reference_to_function_pointer_aux\r
98     : mpl::and_<\r
99           is_reference<T>\r
100         , is_pointer_to_function<\r
101               typename remove_cv<\r
102                   typename remove_reference<T>::type\r
103               >::type\r
104           >\r
105       >\r
106 {\r
107     // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those\r
108 };\r
109 \r
110 template <class T>\r
111 struct is_reference_to_function_pointer\r
112     : mpl::if_<\r
113           is_reference_to_function<T>\r
114         , mpl::false_\r
115         , is_reference_to_function_pointer_aux<T>\r
116      >::type\r
117 {\r
118 };\r
119 \r
120 template <class T>\r
121 struct is_reference_to_non_const\r
122     : mpl::and_<\r
123           is_reference<T>\r
124         , mpl::not_<\r
125              is_reference_to_const<T>\r
126           >\r
127       >\r
128 {\r
129 };\r
130 \r
131 template <class T>\r
132 struct is_reference_to_volatile : mpl::false_\r
133 {\r
134 };\r
135 \r
136 template <class T>\r
137 struct is_reference_to_volatile<T volatile&> : mpl::true_\r
138 {\r
139 };\r
140 \r
141 #   if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround\r
142 template <class T>\r
143 struct is_reference_to_volatile<T const volatile&> : mpl::true_\r
144 {\r
145 };\r
146 #   endif \r
147 \r
148 \r
149 template <class T>\r
150 struct is_reference_to_pointer : mpl::false_\r
151 {\r
152 };\r
153 \r
154 template <class T>\r
155 struct is_reference_to_pointer<T*&> : mpl::true_\r
156 {\r
157 };\r
158 \r
159 template <class T>\r
160 struct is_reference_to_pointer<T* const&> : mpl::true_\r
161 {\r
162 };\r
163 \r
164 template <class T>\r
165 struct is_reference_to_pointer<T* volatile&> : mpl::true_\r
166 {\r
167 };\r
168 \r
169 template <class T>\r
170 struct is_reference_to_pointer<T* const volatile&> : mpl::true_\r
171 {\r
172 };\r
173 \r
174 template <class T>\r
175 struct is_reference_to_class\r
176     : mpl::and_<\r
177           is_reference<T>\r
178         , is_class<\r
179               typename remove_cv<\r
180                   typename remove_reference<T>::type\r
181               >::type\r
182           >\r
183       >\r
184 {\r
185     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))\r
186 };\r
187 \r
188 template <class T>\r
189 struct is_pointer_to_class\r
190     : mpl::and_<\r
191           is_pointer<T>\r
192         , is_class<\r
193               typename remove_cv<\r
194                   typename remove_pointer<T>::type\r
195               >::type\r
196           >\r
197       >\r
198 {\r
199     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T))\r
200 };\r
201 \r
202 #  else\r
203 \r
204 using namespace boost::detail::is_function_ref_tester_;\r
205 \r
206 typedef char (&inner_yes_type)[3];\r
207 typedef char (&inner_no_type)[2];\r
208 typedef char (&outer_no_type)[1];\r
209 \r
210 template <typename V>\r
211 struct is_const_help\r
212 {\r
213     typedef typename mpl::if_<\r
214           is_const<V>\r
215         , inner_yes_type\r
216         , inner_no_type\r
217         >::type type;\r
218 };\r
219 \r
220 template <typename V>\r
221 struct is_volatile_help\r
222 {\r
223     typedef typename mpl::if_<\r
224           is_volatile<V>\r
225         , inner_yes_type\r
226         , inner_no_type\r
227         >::type type;\r
228 };\r
229 \r
230 template <typename V>\r
231 struct is_pointer_help\r
232 {\r
233     typedef typename mpl::if_<\r
234           is_pointer<V>\r
235         , inner_yes_type\r
236         , inner_no_type\r
237         >::type type;\r
238 };\r
239 \r
240 template <typename V>\r
241 struct is_class_help\r
242 {\r
243     typedef typename mpl::if_<\r
244           is_class<V>\r
245         , inner_yes_type\r
246         , inner_no_type\r
247         >::type type;\r
248 };\r
249 \r
250 template <class T>\r
251 struct is_reference_to_function_aux\r
252 {\r
253     static T t;\r
254     BOOST_STATIC_CONSTANT(\r
255         bool, value = sizeof(detail::is_function_ref_tester(t,0)) == sizeof(::boost::type_traits::yes_type));\r
256     typedef mpl::bool_<value> type;\r
257  };\r
258 \r
259 template <class T>\r
260 struct is_reference_to_function\r
261     : mpl::if_<is_reference<T>, is_reference_to_function_aux<T>, mpl::bool_<false> >::type\r
262 {\r
263 };\r
264 \r
265 template <class T>\r
266 struct is_pointer_to_function_aux\r
267 {\r
268     static T t;\r
269     BOOST_STATIC_CONSTANT(\r
270         bool, value\r
271         = sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type));\r
272     typedef mpl::bool_<value> type;\r
273 };\r
274 \r
275 template <class T>\r
276 struct is_pointer_to_function\r
277     : mpl::if_<is_pointer<T>, is_pointer_to_function_aux<T>, mpl::bool_<false> >::type\r
278 {\r
279     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_function,(T))\r
280 };\r
281 \r
282 struct false_helper1\r
283 {\r
284     template <class T>\r
285     struct apply : mpl::false_\r
286     {\r
287     };\r
288 };\r
289 \r
290 template <typename V>\r
291 typename is_const_help<V>::type reference_to_const_helper(V&);    \r
292 outer_no_type\r
293 reference_to_const_helper(...);\r
294 \r
295 struct true_helper1\r
296 {\r
297     template <class T>\r
298     struct apply\r
299     {\r
300         static T t;\r
301         BOOST_STATIC_CONSTANT(\r
302             bool, value\r
303             = sizeof(reference_to_const_helper(t)) == sizeof(inner_yes_type));\r
304         typedef mpl::bool_<value> type;\r
305     };\r
306 };\r
307 \r
308 template <bool ref = true>\r
309 struct is_reference_to_const_helper1 : true_helper1\r
310 {\r
311 };\r
312 \r
313 template <>\r
314 struct is_reference_to_const_helper1<false> : false_helper1\r
315 {\r
316 };\r
317 \r
318 \r
319 template <class T>\r
320 struct is_reference_to_const\r
321     : is_reference_to_const_helper1<is_reference<T>::value>::template apply<T>\r
322 {\r
323 };\r
324 \r
325 \r
326 template <bool ref = true>\r
327 struct is_reference_to_non_const_helper1\r
328 {\r
329     template <class T>\r
330     struct apply\r
331     {\r
332         static T t;\r
333         BOOST_STATIC_CONSTANT(\r
334             bool, value\r
335             = sizeof(reference_to_const_helper(t)) == sizeof(inner_no_type));\r
336         \r
337         typedef mpl::bool_<value> type;\r
338     };\r
339 };\r
340 \r
341 template <>\r
342 struct is_reference_to_non_const_helper1<false> : false_helper1\r
343 {\r
344 };\r
345 \r
346 \r
347 template <class T>\r
348 struct is_reference_to_non_const\r
349     : is_reference_to_non_const_helper1<is_reference<T>::value>::template apply<T>\r
350 {\r
351     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_non_const,(T))\r
352 };\r
353 \r
354 \r
355 template <typename V>\r
356 typename is_volatile_help<V>::type reference_to_volatile_helper(V&);    \r
357 outer_no_type\r
358 reference_to_volatile_helper(...);\r
359 \r
360 template <bool ref = true>\r
361 struct is_reference_to_volatile_helper1\r
362 {\r
363     template <class T>\r
364     struct apply\r
365     {\r
366         static T t;\r
367         BOOST_STATIC_CONSTANT(\r
368             bool, value\r
369             = sizeof(reference_to_volatile_helper(t)) == sizeof(inner_yes_type));\r
370         typedef mpl::bool_<value> type;\r
371     };\r
372 };\r
373 \r
374 template <>\r
375 struct is_reference_to_volatile_helper1<false> : false_helper1\r
376 {\r
377 };\r
378 \r
379 \r
380 template <class T>\r
381 struct is_reference_to_volatile\r
382     : is_reference_to_volatile_helper1<is_reference<T>::value>::template apply<T>\r
383 {\r
384 };\r
385 \r
386 template <typename V>\r
387 typename is_pointer_help<V>::type reference_to_pointer_helper(V&);\r
388 outer_no_type reference_to_pointer_helper(...);\r
389 \r
390 template <class T>\r
391 struct reference_to_pointer_impl\r
392 {\r
393     static T t;\r
394     BOOST_STATIC_CONSTANT(\r
395         bool, value\r
396         = (sizeof((reference_to_pointer_helper)(t)) == sizeof(inner_yes_type))\r
397         );\r
398     \r
399     typedef mpl::bool_<value> type;\r
400 };\r
401     \r
402 template <class T>\r
403 struct is_reference_to_pointer\r
404   : mpl::eval_if<is_reference<T>, reference_to_pointer_impl<T>, mpl::false_>::type\r
405 {   \r
406     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_pointer,(T))\r
407 };\r
408 \r
409 template <class T>\r
410 struct is_reference_to_function_pointer\r
411   : mpl::eval_if<is_reference<T>, is_pointer_to_function_aux<T>, mpl::false_>::type\r
412 {\r
413     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_function_pointer,(T))\r
414 };\r
415 \r
416 \r
417 template <class T>\r
418 struct is_member_function_pointer_help\r
419     : mpl::if_<is_member_function_pointer<T>, inner_yes_type, inner_no_type>\r
420 {};\r
421 \r
422 template <typename V>\r
423 typename is_member_function_pointer_help<V>::type member_function_pointer_helper(V&);\r
424 outer_no_type member_function_pointer_helper(...);\r
425 \r
426 template <class T>\r
427 struct is_pointer_to_member_function_aux\r
428 {\r
429     static T t;\r
430     BOOST_STATIC_CONSTANT(\r
431         bool, value\r
432         = sizeof((member_function_pointer_helper)(t)) == sizeof(inner_yes_type));\r
433     typedef mpl::bool_<value> type;\r
434 };\r
435 \r
436 template <class T>\r
437 struct is_reference_to_member_function_pointer\r
438     : mpl::if_<\r
439         is_reference<T>\r
440         , is_pointer_to_member_function_aux<T>\r
441         , mpl::bool_<false>\r
442      >::type\r
443 {\r
444     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T))\r
445 };\r
446 \r
447 template <typename V>\r
448 typename is_class_help<V>::type reference_to_class_helper(V const volatile&);\r
449 outer_no_type reference_to_class_helper(...);\r
450 \r
451 template <class T>\r
452 struct is_reference_to_class\r
453 {\r
454     static T t;\r
455     BOOST_STATIC_CONSTANT(\r
456         bool, value\r
457         = (is_reference<T>::value\r
458            & (sizeof(reference_to_class_helper(t)) == sizeof(inner_yes_type)))\r
459         );\r
460     typedef mpl::bool_<value> type;\r
461     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T))\r
462 };\r
463 \r
464 template <typename V>\r
465 typename is_class_help<V>::type pointer_to_class_helper(V const volatile*);\r
466 outer_no_type pointer_to_class_helper(...);\r
467 \r
468 template <class T>\r
469 struct is_pointer_to_class\r
470 {\r
471     static T t;\r
472     BOOST_STATIC_CONSTANT(\r
473         bool, value\r
474         = (is_pointer<T>::value\r
475            && sizeof(pointer_to_class_helper(t)) == sizeof(inner_yes_type))\r
476         );\r
477     typedef mpl::bool_<value> type;\r
478 };\r
479 #  endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION \r
480 \r
481 }\r
482 \r
483 using namespace indirect_traits;\r
484 \r
485 }} // namespace boost::python::detail\r
486 \r
487 #endif // INDIRECT_TRAITS_DWA2002131_HPP\r