Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:11

0001 
0002 //  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
0003 //  Hinnant & John Maddock 2000.  
0004 //  Use, modification and distribution are subject to the Boost Software License,
0005 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt).
0007 //
0008 //  See http://www.boost.org/libs/type_traits for most recent version including documentation.
0009 
0010 
0011 #ifndef BOOST_TT_IS_ENUM_HPP_INCLUDED
0012 #define BOOST_TT_IS_ENUM_HPP_INCLUDED
0013 
0014 #include <boost/type_traits/intrinsics.hpp>
0015 #include <boost/type_traits/integral_constant.hpp>
0016 #ifndef BOOST_IS_ENUM
0017 #include <boost/type_traits/add_reference.hpp>
0018 #include <boost/type_traits/is_arithmetic.hpp>
0019 #include <boost/type_traits/is_reference.hpp>
0020 #include <boost/type_traits/is_convertible.hpp>
0021 #include <boost/type_traits/is_array.hpp>
0022 #ifdef __GNUC__
0023 #include <boost/type_traits/is_function.hpp>
0024 #endif
0025 #include <boost/type_traits/detail/config.hpp>
0026 #if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) 
0027 #  include <boost/type_traits/is_class.hpp>
0028 #  include <boost/type_traits/is_union.hpp>
0029 #endif
0030 #endif
0031 
0032 namespace boost {
0033 
0034 #ifndef BOOST_IS_ENUM
0035 #if !(defined(BOOST_BORLANDC) && (BOOST_BORLANDC <= 0x551))
0036 
0037 namespace detail {
0038 
0039 #if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) 
0040 
0041 template <typename T>
0042 struct is_class_or_union
0043 {
0044    BOOST_STATIC_CONSTANT(bool, value = ::boost::is_class<T>::value || ::boost::is_union<T>::value);
0045 };
0046 
0047 #else
0048 
0049 template <typename T>
0050 struct is_class_or_union
0051 {
0052 # if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))// we simply can't detect it this way.
0053     BOOST_STATIC_CONSTANT(bool, value = false);
0054 # else
0055     template <class U> static ::boost::type_traits::yes_type is_class_or_union_tester(void(U::*)(void));
0056 
0057 #  if BOOST_WORKAROUND(__MWERKS__, <= 0x3000) // no SFINAE
0058     static ::boost::type_traits::no_type is_class_or_union_tester(...);
0059     BOOST_STATIC_CONSTANT(
0060         bool, value = sizeof(is_class_or_union_tester(0)) == sizeof(::boost::type_traits::yes_type));
0061 #  else
0062     template <class U>
0063     static ::boost::type_traits::no_type is_class_or_union_tester(...);
0064     BOOST_STATIC_CONSTANT(
0065         bool, value = sizeof(is_class_or_union_tester<T>(0)) == sizeof(::boost::type_traits::yes_type));
0066 #  endif
0067 # endif
0068 };
0069 #endif
0070 
0071 struct int_convertible
0072 {
0073     int_convertible(int);
0074 };
0075 
0076 // Don't evaluate convertibility to int_convertible unless the type
0077 // is non-arithmetic. This suppresses warnings with GCC.
0078 template <bool is_typename_arithmetic_or_reference = true>
0079 struct is_enum_helper
0080 {
0081     template <typename T> struct type
0082     {
0083         BOOST_STATIC_CONSTANT(bool, value = false);
0084     };
0085 };
0086 
0087 template <>
0088 struct is_enum_helper<false>
0089 {
0090     template <typename T> struct type
0091     {
0092        static const bool value = ::boost::is_convertible<typename boost::add_reference<T>::type, ::boost::detail::int_convertible>::value;
0093     };
0094 };
0095 
0096 template <typename T> struct is_enum_impl
0097 {
0098    //typedef ::boost::add_reference<T> ar_t;
0099    //typedef typename ar_t::type r_type;
0100 
0101 #if defined(__GNUC__)
0102 
0103 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
0104     
0105    // We MUST check for is_class_or_union on conforming compilers in
0106    // order to correctly deduce that noncopyable types are not enums
0107    // (dwa 2002/04/15)...
0108    BOOST_STATIC_CONSTANT(bool, selector =
0109            ::boost::is_arithmetic<T>::value
0110          || ::boost::is_reference<T>::value
0111          || ::boost::is_function<T>::value
0112          || is_class_or_union<T>::value
0113          || is_array<T>::value);
0114 #else
0115    // ...however, not checking is_class_or_union on non-conforming
0116    // compilers prevents a dependency recursion.
0117    BOOST_STATIC_CONSTANT(bool, selector =
0118            ::boost::is_arithmetic<T>::value
0119          || ::boost::is_reference<T>::value
0120          || ::boost::is_function<T>::value
0121          || is_array<T>::value);
0122 #endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
0123 
0124 #else // !defined(__GNUC__):
0125     
0126    BOOST_STATIC_CONSTANT(bool, selector =
0127            ::boost::is_arithmetic<T>::value
0128          || ::boost::is_reference<T>::value
0129          || is_class_or_union<T>::value
0130          || is_array<T>::value);
0131     
0132 #endif
0133 
0134 #if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600)
0135     typedef ::boost::detail::is_enum_helper<
0136           ::boost::detail::is_enum_impl<T>::selector
0137         > se_t;
0138 #else
0139     typedef ::boost::detail::is_enum_helper<selector> se_t;
0140 #endif
0141 
0142     typedef typename se_t::template type<T> helper;
0143     BOOST_STATIC_CONSTANT(bool, value = helper::value);
0144 };
0145 
0146 } // namespace detail
0147 
0148 template <class T> struct is_enum : public integral_constant<bool, ::boost::detail::is_enum_impl<T>::value> {};
0149 
0150 #else // BOOST_BORLANDC
0151 //
0152 // buggy is_convertible prevents working
0153 // implementation of is_enum:
0154 template <class T> struct is_enum : public integral_constant<bool, false> {};
0155 
0156 #endif
0157 
0158 #else // BOOST_IS_ENUM
0159 
0160 template <class T> struct is_enum : public integral_constant<bool, BOOST_IS_ENUM(T)> {};
0161 
0162 #endif
0163 
0164 } // namespace boost
0165 
0166 #endif // BOOST_TT_IS_ENUM_HPP_INCLUDED