Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _EXT_NUMERIC_TRAITS
00030 #define _EXT_NUMERIC_TRAITS 1
00031
00032 #pragma GCC system_header
00033
00034 #include <bits/cpp_type_traits.h>
00035 #include <ext/type_traits.h>
00036
00037 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
00038 {
00039 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00040
00041
00042
00043 #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
00044 #define __glibcxx_digits(_Tp) \
00045 (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
00046
00047 #define __glibcxx_min(_Tp) \
00048 (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
00049
00050 #define __glibcxx_max(_Tp) \
00051 (__glibcxx_signed(_Tp) ? \
00052 (((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
00053
00054 template<typename _Value>
00055 struct __numeric_traits_integer
00056 {
00057
00058 static const _Value __min = __glibcxx_min(_Value);
00059 static const _Value __max = __glibcxx_max(_Value);
00060
00061
00062
00063 static const bool __is_signed = __glibcxx_signed(_Value);
00064 static const int __digits = __glibcxx_digits(_Value);
00065 };
00066
00067 template<typename _Value>
00068 const _Value __numeric_traits_integer<_Value>::__min;
00069
00070 template<typename _Value>
00071 const _Value __numeric_traits_integer<_Value>::__max;
00072
00073 template<typename _Value>
00074 const bool __numeric_traits_integer<_Value>::__is_signed;
00075
00076 template<typename _Value>
00077 const int __numeric_traits_integer<_Value>::__digits;
00078
00079 #undef __glibcxx_signed
00080 #undef __glibcxx_digits
00081 #undef __glibcxx_min
00082 #undef __glibcxx_max
00083
00084 #define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \
00085 (std::__are_same<_Tp, float>::__value ? _Fval \
00086 : std::__are_same<_Tp, double>::__value ? _Dval : _LDval)
00087
00088 #define __glibcxx_max_digits10(_Tp) \
00089 (2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \
00090 __LDBL_MANT_DIG__) * 643L / 2136)
00091
00092 #define __glibcxx_digits10(_Tp) \
00093 __glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__)
00094
00095 #define __glibcxx_max_exponent10(_Tp) \
00096 __glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \
00097 __LDBL_MAX_10_EXP__)
00098
00099 template<typename _Value>
00100 struct __numeric_traits_floating
00101 {
00102
00103 static const int __max_digits10 = __glibcxx_max_digits10(_Value);
00104
00105
00106 static const bool __is_signed = true;
00107 static const int __digits10 = __glibcxx_digits10(_Value);
00108 static const int __max_exponent10 = __glibcxx_max_exponent10(_Value);
00109 };
00110
00111 template<typename _Value>
00112 const int __numeric_traits_floating<_Value>::__max_digits10;
00113
00114 template<typename _Value>
00115 const bool __numeric_traits_floating<_Value>::__is_signed;
00116
00117 template<typename _Value>
00118 const int __numeric_traits_floating<_Value>::__digits10;
00119
00120 template<typename _Value>
00121 const int __numeric_traits_floating<_Value>::__max_exponent10;
00122
00123 template<typename _Value>
00124 struct __numeric_traits
00125 : public __conditional_type<std::__is_integer<_Value>::__value,
00126 __numeric_traits_integer<_Value>,
00127 __numeric_traits_floating<_Value> >::__type
00128 { };
00129
00130 _GLIBCXX_END_NAMESPACE_VERSION
00131 }
00132
00133 #undef __glibcxx_floating
00134 #undef __glibcxx_max_digits10
00135 #undef __glibcxx_digits10
00136 #undef __glibcxx_max_exponent10
00137
00138 #endif