File indexing completed on 2025-01-18 09:53:11
0001
0002
0003
0004
0005
0006
0007
0008
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))
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)
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
0077
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
0099
0100
0101 #if defined(__GNUC__)
0102
0103 #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
0104
0105
0106
0107
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
0116
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
0123
0124 #else
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 }
0147
0148 template <class T> struct is_enum : public integral_constant<bool, ::boost::detail::is_enum_impl<T>::value> {};
0149
0150 #else
0151
0152
0153
0154 template <class T> struct is_enum : public integral_constant<bool, false> {};
0155
0156 #endif
0157
0158 #else
0159
0160 template <class T> struct is_enum : public integral_constant<bool, BOOST_IS_ENUM(T)> {};
0161
0162 #endif
0163
0164 }
0165
0166 #endif