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
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901
00066 # define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
00067
00068 # include <sysc/packages/boost/config.hpp>
00069 # include <sysc/packages/boost/cstdint.hpp>
00070 # include <sysc/packages/boost/static_assert.hpp>
00071 # include <sysc/packages/boost/type_traits.hpp>
00072 # include <sysc/packages/boost/detail/select_type.hpp>
00073 # include <sysc/packages/boost/limits.hpp>
00074
00075 namespace boost { namespace detail {
00076
00077
00078
00079
00080
00081 template <class Number>
00082 struct is_signed
00083 {
00084 #if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_MSVC) && BOOST_MSVC <= 1300
00085 BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0)));
00086 #else
00087 BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<Number>::is_signed);
00088 #endif
00089 };
00090
00091 # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
00092
00093
00094
00095 template <bool is_specialized> struct digit_traits_select;
00096
00097
00098 template <> struct digit_traits_select<true>
00099 {
00100 template <class T> struct traits
00101 {
00102 BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
00103 };
00104 };
00105
00106
00107 template <> struct digit_traits_select<false>
00108 {
00109 template <class T> struct traits
00110 {
00111 BOOST_STATIC_CONSTANT(int, digits = (
00112 sizeof(T) * std::numeric_limits<unsigned char>::digits
00113 - (is_signed<T>::value ? 1 : 0))
00114 );
00115 };
00116 };
00117
00118
00119 template <class T> struct digit_traits
00120 {
00121 typedef digit_traits_select<
00122 ::std::numeric_limits<T>::is_specialized> selector;
00123 typedef typename selector::template traits<T> traits;
00124 BOOST_STATIC_CONSTANT(int, digits = traits::digits);
00125 };
00126 #endif
00127
00128
00129
00130
00131 template <class Integer>
00132 struct integer_traits
00133 {
00134 # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
00135 private:
00136 typedef Integer integer_type;
00137 typedef std::numeric_limits<integer_type> x;
00138 # if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
00139
00140
00141 BOOST_STATIC_CONSTANT(bool, is_integer = x::is_integer);
00142 BOOST_STATIC_CONSTANT(bool, is_specialized = x::is_specialized);
00143
00144 BOOST_STATIC_ASSERT(is_integer);
00145 BOOST_STATIC_ASSERT(is_specialized);
00146 # endif
00147 public:
00148 typedef typename
00149 if_true<(int(x::is_signed)
00150 && (!int(x::is_bounded)
00151
00152 || (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits)))>::template then<
00153 Integer,
00154
00155 typename if_true<(int(x::digits) + 1 < digit_traits<signed int>::digits)>::template then<
00156 signed int,
00157
00158 typename if_true<(int(x::digits) + 1 < digit_traits<signed long>::digits)>::template then<
00159 signed long,
00160
00161
00162 intmax_t
00163 >::type>::type>::type difference_type;
00164 #else
00165 BOOST_STATIC_ASSERT(boost::is_integral<Integer>::value);
00166
00167 typedef typename
00168 if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then<
00169
00170 typename if_true<(is_signed<Integer>::value)>::template then<
00171 Integer,
00172 intmax_t
00173 >::type,
00174
00175 typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then<
00176 std::ptrdiff_t,
00177 intmax_t
00178 >::type
00179 >::type difference_type;
00180 # endif
00181 };
00182
00183
00184 template <class Number>
00185 struct numeric_traits
00186 {
00187 typedef typename integer_traits<Number>::difference_type difference_type;
00188 };
00189
00190 template <class Number>
00191 typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
00192 {
00193 typedef typename numeric_traits<Number>::difference_type difference_type;
00194 return difference_type(y) - difference_type(x);
00195 }
00196 }}
00197
00198 #endif // BOOST_NUMERIC_TRAITS_HPP_DWA20001901