]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_enum.hpp
update to boost 1.30.1
[lyx.git] / boost / boost / type_traits / is_enum.hpp
1
2 // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
3 // Hinnant & John Maddock 2000.  Permission to copy, use, modify,
4 // sell and distribute this software is granted provided this
5 // copyright notice appears in all copies. This software is provided
6 // "as is" without express or implied warranty, and with no claim as
7 // to its suitability for any purpose.
8 //
9 // See http://www.boost.org for most recent version including documentation.
10
11 #ifndef BOOST_TT_IS_ENUM_HPP_INCLUDED
12 #define BOOST_TT_IS_ENUM_HPP_INCLUDED
13
14 #include "boost/type_traits/add_reference.hpp"
15 #include "boost/type_traits/is_arithmetic.hpp"
16 #include "boost/type_traits/is_reference.hpp"
17 #include "boost/type_traits/is_convertible.hpp"
18 #include "boost/type_traits/config.hpp"
19
20 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
21 #   include "boost/type_traits/is_class.hpp"
22 #endif
23
24 // should be the last #include
25 #include "boost/type_traits/detail/bool_trait_def.hpp"
26
27 namespace boost {
28
29 #if !(defined(__BORLANDC__) && (__BORLANDC__ <= 0x551))
30
31 namespace detail {
32   
33 struct int_convertible
34 {
35     int_convertible(int);
36 };
37
38 // Don't evaluate convertibility to int_convertible unless the type
39 // is non-arithmetic. This suppresses warnings with GCC.
40 template <bool is_typename_arithmetic_or_reference = true>
41 struct is_enum_helper
42 {
43     template <typename T> struct type
44     {
45         BOOST_STATIC_CONSTANT(bool, value = false);
46     };
47 };
48
49 template <>
50 struct is_enum_helper<false>
51 {
52     template <typename T> struct type
53         : ::boost::is_convertible<T,::boost::detail::int_convertible>
54     {
55     };
56 };
57
58 template <typename T> struct is_enum_impl
59 {
60    typedef ::boost::add_reference<T> ar_t;
61    typedef typename ar_t::type r_type;
62        
63 #if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
64    BOOST_STATIC_CONSTANT(bool, selector =
65       (::boost::type_traits::ice_or<
66            ::boost::is_arithmetic<T>::value
67          , ::boost::is_reference<T>::value
68        // We MUST do this on conforming compilers in order to
69        // correctly deduce that noncopyable types are not enums (dwa
70        // 2002/04/15)...
71          , ::boost::is_class<T>::value
72       >::value));
73 #else 
74    BOOST_STATIC_CONSTANT(bool, selector =
75       (::boost::type_traits::ice_or<
76            ::boost::is_arithmetic<T>::value
77          , ::boost::is_reference<T>::value
78        // However, not doing this on non-conforming compilers prevents
79        // a dependency recursion.
80       >::value));
81 #endif
82
83 #ifdef __BORLANDC__
84     typedef ::boost::detail::is_enum_helper<
85           ::boost::detail::is_enum_impl<T>::selector
86         > se_t;
87 #else
88     typedef ::boost::detail::is_enum_helper<selector> se_t;
89 #endif
90     typedef typename se_t::template type<r_type> helper;
91     BOOST_STATIC_CONSTANT(bool, value = helper::value);
92 };
93
94 // Specializations suppress some nasty warnings with GCC
95 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,float,false)
96 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,double,false)
97 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,long double,false)
98 // these help on compilers with no partial specialization support:
99 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void,false)
100 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
101 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void const,false)
102 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void volatile,false)
103 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_enum,void const volatile,false)
104 #endif
105
106 } // namespace detail
107
108 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,::boost::detail::is_enum_impl<T>::value)
109
110 #else // __BORLANDC__
111 //
112 // buggy is_convertible prevents working 
113 // implementation of is_enum:
114 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,false)
115
116 #endif
117
118 } // namespace boost
119
120 #include "boost/type_traits/detail/bool_trait_undef.hpp"
121
122 #endif // BOOST_TT_IS_ENUM_HPP_INCLUDED