source: XIOS/dev/dev_olga/src/extern/boost/include/boost/detail/indirect_traits.hpp @ 1022

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