File indexing completed on 2024-11-15 09:33:08
0001
0002
0003
0004
0005
0006 #ifndef BOOST_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
0007 #define BOOST_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
0008
0009 #include <boost/config.hpp>
0010 #include <boost/detail/workaround.hpp>
0011
0012 #if (BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
0013 || BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610)) \
0014 || BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) \
0015 || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) \
0016 || BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, BOOST_TESTED_AT(810)) )\
0017 || defined(BOOST_MPL_CFG_NO_ADL_BARRIER_NAMESPACE)
0018
0019
0020 namespace boost{
0021 namespace mpl
0022 {
0023 template <bool B> struct bool_;
0024 template <class I, I val> struct integral_c;
0025 struct integral_c_tag;
0026 }
0027 }
0028
0029 #else
0030
0031 namespace mpl_{
0032
0033 template <bool B> struct bool_;
0034 template <class I, I val> struct integral_c;
0035 struct integral_c_tag;
0036 }
0037
0038 namespace boost
0039 {
0040 namespace mpl
0041 {
0042 using ::mpl_::bool_;
0043 using ::mpl_::integral_c;
0044 using ::mpl_::integral_c_tag;
0045 }
0046 }
0047
0048 #endif
0049
0050 namespace boost{
0051
0052 template <class T, T val>
0053 struct integral_constant
0054 {
0055 typedef mpl::integral_c_tag tag;
0056 typedef T value_type;
0057 typedef integral_constant<T, val> type;
0058 static const T value = val;
0059
0060 operator const mpl::integral_c<T, val>& ()const
0061 {
0062 static const char data[sizeof(long)] = { 0 };
0063 static const void* pdata = data;
0064 return *(reinterpret_cast<const mpl::integral_c<T, val>*>(pdata));
0065 }
0066 BOOST_CONSTEXPR operator T()const { return val; }
0067 };
0068
0069 template <class T, T val>
0070 T const integral_constant<T, val>::value;
0071
0072 template <bool val>
0073 struct integral_constant<bool, val>
0074 {
0075 typedef mpl::integral_c_tag tag;
0076 typedef bool value_type;
0077 typedef integral_constant<bool, val> type;
0078 static const bool value = val;
0079
0080 operator const mpl::bool_<val>& ()const
0081 {
0082 static const char data[sizeof(long)] = { 0 };
0083 static const void* pdata = data;
0084 return *(reinterpret_cast<const mpl::bool_<val>*>(pdata));
0085 }
0086 BOOST_CONSTEXPR operator bool()const { return val; }
0087 };
0088
0089 template <bool val>
0090 bool const integral_constant<bool, val>::value;
0091
0092 typedef integral_constant<bool, true> true_type;
0093 typedef integral_constant<bool, false> false_type;
0094
0095 }
0096
0097 #endif