source: vendor/nemo/current/NEMOGCM/EXTERNAL/XIOS/extern/boost/include/boost/type_traits/is_enum.hpp @ 44

Last change on this file since 44 was 44, checked in by cholod, 12 years ago

Load NEMO_TMP into vendor/nemo/current.

File size: 5.5 KB
Line 
1
2//  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
3//  Hinnant & John Maddock 2000. 
4//  Use, modification and distribution are subject to the Boost Software License,
5//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt).
7//
8//  See http://www.boost.org/libs/type_traits for most recent version including documentation.
9
10
11#ifndef BOOST_TT_IS_ENUM_HPP_INCLUDED
12#define BOOST_TT_IS_ENUM_HPP_INCLUDED
13
14#include <boost/type_traits/intrinsics.hpp>
15#ifndef BOOST_IS_ENUM
16#include <boost/type_traits/add_reference.hpp>
17#include <boost/type_traits/is_arithmetic.hpp>
18#include <boost/type_traits/is_reference.hpp>
19#include <boost/type_traits/is_convertible.hpp>
20#include <boost/type_traits/is_array.hpp>
21#ifdef __GNUC__
22#include <boost/type_traits/is_function.hpp>
23#endif
24#include <boost/type_traits/config.hpp>
25#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
26#  include <boost/type_traits/is_class.hpp>
27#  include <boost/type_traits/is_union.hpp>
28#endif
29#endif
30
31// should be the last #include
32#include <boost/type_traits/detail/bool_trait_def.hpp>
33
34namespace boost {
35
36#ifndef BOOST_IS_ENUM
37#if !(defined(__BORLANDC__) && (__BORLANDC__ <= 0x551))
38
39namespace detail {
40
41#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
42
43template <typename T>
44struct is_class_or_union
45{
46   BOOST_STATIC_CONSTANT(bool, value =
47      (::boost::type_traits::ice_or<
48           ::boost::is_class<T>::value
49         , ::boost::is_union<T>::value
50      >::value));
51};
52
53#else
54
55template <typename T>
56struct is_class_or_union
57{
58# if BOOST_WORKAROUND(BOOST_MSVC, < 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))// we simply can't detect it this way.
59    BOOST_STATIC_CONSTANT(bool, value = false);
60# else
61    template <class U> static ::boost::type_traits::yes_type is_class_or_union_tester(void(U::*)(void));
62
63#  if BOOST_WORKAROUND(BOOST_MSVC, == 1300)                 \
64    || BOOST_WORKAROUND(__MWERKS__, <= 0x3000) // no SFINAE
65    static ::boost::type_traits::no_type is_class_or_union_tester(...);
66    BOOST_STATIC_CONSTANT(
67        bool, value = sizeof(is_class_or_union_tester(0)) == sizeof(::boost::type_traits::yes_type));
68#  else
69    template <class U>
70    static ::boost::type_traits::no_type is_class_or_union_tester(...);
71    BOOST_STATIC_CONSTANT(
72        bool, value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(::boost::type_traits::yes_type));
73#  endif
74# endif
75};
76#endif
77
78struct int_convertible
79{
80    int_convertible(int);
81};
82
83// Don't evaluate convertibility to int_convertible unless the type
84// is non-arithmetic. This suppresses warnings with GCC.
85template <bool is_typename_arithmetic_or_reference = true>
86struct is_enum_helper
87{
88    template <typename T> struct type
89    {
90        BOOST_STATIC_CONSTANT(bool, value = false);
91    };
92};
93
94template <>
95struct is_enum_helper<false>
96{
97    template <typename T> struct type
98       : ::boost::is_convertible<typename boost::add_reference<T>::type,::boost::detail::int_convertible>
99    {
100    };
101};
102
103template <typename T> struct is_enum_impl
104{
105   //typedef ::boost::add_reference<T> ar_t;
106   //typedef typename ar_t::type r_type;
107
108#if defined(__GNUC__)
109
110#ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
111   
112   // We MUST check for is_class_or_union on conforming compilers in
113   // order to correctly deduce that noncopyable types are not enums
114   // (dwa 2002/04/15)...
115   BOOST_STATIC_CONSTANT(bool, selector =
116      (::boost::type_traits::ice_or<
117           ::boost::is_arithmetic<T>::value
118         , ::boost::is_reference<T>::value
119         , ::boost::is_function<T>::value
120         , is_class_or_union<T>::value
121         , is_array<T>::value
122      >::value));
123#else
124   // ...however, not checking is_class_or_union on non-conforming
125   // compilers prevents a dependency recursion.
126   BOOST_STATIC_CONSTANT(bool, selector =
127      (::boost::type_traits::ice_or<
128           ::boost::is_arithmetic<T>::value
129         , ::boost::is_reference<T>::value
130         , ::boost::is_function<T>::value
131         , is_array<T>::value
132      >::value));
133#endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
134
135#else // !defined(__GNUC__):
136   
137   BOOST_STATIC_CONSTANT(bool, selector =
138      (::boost::type_traits::ice_or<
139           ::boost::is_arithmetic<T>::value
140         , ::boost::is_reference<T>::value
141         , is_class_or_union<T>::value
142         , is_array<T>::value
143      >::value));
144   
145#endif
146
147#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
148    typedef ::boost::detail::is_enum_helper<
149          ::boost::detail::is_enum_impl<T>::selector
150        > se_t;
151#else
152    typedef ::boost::detail::is_enum_helper<selector> se_t;
153#endif
154
155    typedef typename se_t::template type<T> helper;
156    BOOST_STATIC_CONSTANT(bool, value = helper::value);
157};
158
159// these help on compilers with no partial specialization support:
160BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void,false)
161#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
162BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void const,false)
163BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void volatile,false)
164BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void const volatile,false)
165#endif
166
167} // namespace detail
168
169BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,::boost::detail::is_enum_impl<T>::value)
170
171#else // __BORLANDC__
172//
173// buggy is_convertible prevents working
174// implementation of is_enum:
175BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,false)
176
177#endif
178
179#else // BOOST_IS_ENUM
180
181BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,BOOST_IS_ENUM(T))
182
183#endif
184
185} // namespace boost
186
187#include <boost/type_traits/detail/bool_trait_undef.hpp>
188
189#endif // BOOST_TT_IS_ENUM_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.