Boost logo

Boost :

From: DY, JERRY U \(SBCSI\) (jd2419_at_[hidden])
Date: 2004-07-28 14:04:19


In boost/detail/numeric_traits.hpp, integer_traits can be used to find
the difference_type for an int type, in aC++, I get a long long -- I
don't think that's the correct result, but can somebody please tell me
why not? Thanks!

integer_traits<int>::difference_type // long long?? I expect this to
be an int

Here's why:

template <class Integer, bool = true>
  struct integer_traits
 {
...
typedef typename
      if_true<(int(x::is_signed) // true
              && (!int(x::is_bounded) // true
                  || (int(x::digits) + 1 >=
digit_traits<boost::intmax_t>::digits))) // false
>::template then<
        Integer,

      typename if_true<(int(x::digits) + 1 < digit_traits<signed
int>::digits)>::template then< // false
        signed int,

      typename if_true<(int(x::digits) + 1 < digit_traits<signed
long>::digits)>::template then< // false
        signed long,

   // else
        intmax_t // this is long long
>::type>::type>::type difference_type;

...
}

-Jerry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk