Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2002-09-25 14:54:19


At 01:30 PM 9/25/2002, Jeffrey C. Jacobs wrote:
>Oops! My bad!
>
>Actually, the MSVC++ compiler considers __int<x> as separate types from int,
>long, etc. (having checked the name mangling -- what a mess they make of
>specializations with these MS-types!!). Let me consider the issue further
>and get back to y'all but my belief remains that we should not assume
>__int64 == long long, specifically when my theory is "long long" will not be
>standardized at 64 bits, simply bigger or as big as long.

Unless C++ fails to follow C99 your theory is wrong:

5.2.4.2.1 Sizes of integer types <limits.h>

The values given below shall be replaced by
constant expressions suitable for use in #if
preprocessing directives. Moreover, except for
CHAR_BIT and MB_LEN_MAX, the following shall be
replaced by expressions that have the same type
as would an expression that is an object of the
corresponding type converted according to the
integer promotions. Their implementation-defined
values shall be equal or greater in magnitude
(absolute value) to those shown, with the same
sign.

..

- minimum value for an object of type long long int
LLONG_MIN -9223372036854775807 // -(2**63 - 1)

— maximum value for an object of type long long int
LLONG_MAX +9223372036854775807 // 2**63 - 1

— maximum value for an object of type unsigned long long int
ULLONG_MAX 18446744073709551615 // 26**4 - 1

>Thus:
>
>int_least_helper<1> => long long
>int_least_helper<2> => long
>.
>
>Should always work but:
>
>int_least_helper<1> => __int64
>int_least_helper<2> => long
>.
>
>Has a remote possiblity of failing, specifically if sizeof(long) > 8, which
>I would not rule out in the long term. (Pardon my pun!)
>
>As for how to handle long long,
>
>I suggest:
>
>#if defined(BOOST_LONG_LONG_...)
>template<> struct int_least_helper<1> { typedef long long least; };
>#endif
>template<> struct int_least_helper<2> { typedef long least; };
>.
>
>struct int_t
>{
>.
>#if defined(BOOST_LONG_LONG_...)
> (Bits-1 <= std::numeric_limits<long long>::digits) +
>#else
> 1+
>#endif
> (Bits-1 <= std::numeric_limits<long>::digits) +
>.
>}
>.
>
>That would allow compatibility in internal structure between long long
>compliant compilers and those non-compliant (2 is always long, etc.).
>
>Any thoughts on that approach?
>
>Jeffrey.
>
>
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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