numeric_traits.h
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
00030
00031
00032
00033
00034
00035 #ifndef _EXT_NUMERIC_TRAITS
00036 #define _EXT_NUMERIC_TRAITS 1
00037
00038 #pragma GCC system_header
00039
00040 #include <limits>
00041 #include <bits/cpp_type_traits.h>
00042 #include <ext/type_traits.h>
00043
00044 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00045
00046
00047
00048 #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
00049 #define __glibcxx_digits(_Tp) \
00050 (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
00051
00052 #define __glibcxx_min(_Tp) \
00053 (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
00054
00055 #define __glibcxx_max(_Tp) \
00056 (__glibcxx_signed(_Tp) ? \
00057 (((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
00058
00059 template<typename _Value>
00060 struct __numeric_traits_integer
00061 {
00062
00063 static const _Value __min = __glibcxx_min(_Value);
00064 static const _Value __max = __glibcxx_max(_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 struct __numeric_traits_floating
00075 {
00076
00077 static const int __max_digits10 =
00078 2 + std::numeric_limits<_Value>::digits * 3010/10000;
00079 };
00080
00081 template<typename _Value>
00082 const int __numeric_traits_floating<_Value>::__max_digits10;
00083
00084 template<typename _Value>
00085 struct __numeric_traits
00086 : public __conditional_type<std::__is_integer<_Value>::__value,
00087 __numeric_traits_integer<_Value>,
00088 __numeric_traits_floating<_Value> >::__type
00089 { };
00090
00091 _GLIBCXX_END_NAMESPACE
00092
00093 #undef __glibcxx_signed
00094 #undef __glibcxx_min
00095 #undef __glibcxx_max
00096 #undef __glibcxx_digits
00097
00098 #endif