Compare commits

..

57 Commits

Author SHA1 Message Date
12c7a44062 This commit was manufactured by cvs2svn to create branch 'mpl_v2_2'.
[SVN r18675]
2003-06-05 05:15:05 +00:00
890e28ab67 include <boost/limits.hpp> instead of <limits.h>, fixing a date-time issue on Comeau
[SVN r18499]
2003-05-22 18:09:32 +00:00
1252426554 Added Cray X1 support
[SVN r17022]
2003-01-24 11:57:27 +00:00
19fb03cefe Added Cray support
[SVN r16989]
2003-01-22 12:12:14 +00:00
a9b35df2f8 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
49a8d69fe3 minor fix for integer_traits,
changed is_pod.hpp include to is_POD.hpp as a temporary fix


[SVN r15996]
2002-10-27 12:16:39 +00:00
9cc587a7f2 Merged changes from RC_1_29_0 branch
[SVN r15958]
2002-10-21 11:00:50 +00:00
2de1422682 boost/test/minimal.hpp
[SVN r15234]
2002-09-09 11:58:24 +00:00
344fe9f30a clear un/signed warnings
[SVN r14692]
2002-08-05 11:16:14 +00:00
8ad3bbafbc BOOST_HAS_MS_INT64 rather than specific compilers
[SVN r14668]
2002-08-05 00:02:10 +00:00
cc1183d347 Check for BOOST_HAS_MS_INT64 instead of specific compilers
[SVN r14664]
2002-08-04 01:27:24 +00:00
a9703fa803 Fix link
[SVN r14630]
2002-07-27 20:08:51 +00:00
5e26f47535 Fixed test case for VC7.0
[SVN r14627]
2002-07-27 11:47:04 +00:00
57e7ccd494 Fix unversioned VC++ checks
[SVN r14436]
2002-07-13 12:26:19 +00:00
c56e4674f8 Update from Daryle
[SVN r14187]
2002-06-19 20:11:17 +00:00
41620a14f9 Patched so that the code now compilers with VC6
[SVN r13669]
2002-05-05 11:00:28 +00:00
a42ede713e fix link
[SVN r12698]
2002-02-04 18:55:31 +00:00
92de2f44a0 cstdint.hpp:
- Handle FreeBSD's <inttypes.h>


[SVN r12601]
2002-01-31 12:58:35 +00:00
59779dec2c integer_traits.hpp:
- Handle wchar_t traits on FreeBSD


[SVN r12467]
2002-01-23 19:56:07 +00:00
3bb567ad9d initial checkin
[SVN r11972]
2001-12-07 13:19:38 +00:00
c50993d5d4 Added daryle's missing files
[SVN r11971]
2001-12-07 12:48:20 +00:00
5477a9641c initial checkin
[SVN r11898]
2001-12-03 23:55:35 +00:00
162c6aefa1 Integrated Daryle Walker's dlw_int.zip changes
[SVN r11866]
2001-12-03 03:29:57 +00:00
24e6bfbfaa add definition for integral constants initialized in-class
[SVN r11724]
2001-11-18 17:37:21 +00:00
ccabb522d0 Remove non-ASCII character that crept in.
[SVN r11570]
2001-11-04 21:53:21 +00:00
0995d0a6fb only use "long long" if there's a stdlib overload
[SVN r11516]
2001-11-01 21:52:08 +00:00
5ec8116c34 use BOOST_HAS_LONG_LONG
[SVN r11493]
2001-10-31 19:35:59 +00:00
4a094c4bcb fix wchar_t on HP-UX with gcc
[SVN r11472]
2001-10-30 20:55:18 +00:00
a7d2da8d1c 1.25.0 Final runup
[SVN r11315]
2001-10-01 15:54:23 +00:00
4d2a921dbf Write out limits as integers, even for char types.
[SVN r11301]
2001-09-28 17:38:10 +00:00
0c758855e4 Since it's obsolete, it should be removed.
[SVN r11300]
2001-09-28 17:37:25 +00:00
3399df597e Add case for Mac OS X to the WCHAR_MIN/WCHAR_MAX section.
[SVN r11242]
2001-09-24 23:45:49 +00:00
a066e242b0 always use WCHAR_MIN and WCHAR_MAX if defined
[SVN r11232]
2001-09-24 18:43:20 +00:00
a635f753a4 port cstdint.hpp to HP-UX
[SVN r11175]
2001-09-20 19:25:35 +00:00
08f30ea46c moved check, because different unsigned types may have different
representations for -1 (e.g. (unsigned char)-1 and (unsigned int)-1)


[SVN r11174]
2001-09-20 19:24:34 +00:00
292eeb5c90 Fixes for broken using declarations
[SVN r11164]
2001-09-20 11:44:34 +00:00
8a105dab3f Fixes for the case that platform has its own stdint.h (less stringent tests)
[SVN r11163]
2001-09-20 11:44:05 +00:00
5b0d514aa4 commit of split-config, including any changes required to existing libraries (mainly regex).
[SVN r11138]
2001-09-18 11:13:39 +00:00
eee6dfa4d9 avoid "long long" with SunCC (Gennadiy E. Rozental)
[SVN r11066]
2001-09-07 18:49:12 +00:00
3bd242ef49 Fix broken hyperlink
[SVN r10896]
2001-08-19 15:08:33 +00:00
3db9390efb Add LL suffix to line 150 for long longs at suggestion of Toon Knapen
[SVN r10854]
2001-08-13 17:02:48 +00:00
c6f3dce91a Fixed VC6+STLport-4.1b6 (changed preprocessor logic)
[SVN r10360]
2001-06-20 11:42:44 +00:00
3e2b929118 free -> fee
[SVN r10248]
2001-05-31 17:22:20 +00:00
645f809379 fix the "gcc 3.0 and long long" fix to check for the appropriate symbol
[SVN r10107]
2001-05-13 18:17:15 +00:00
28ec7fa76c Don't use "long long" with gcc 3.0's shipped library, because it does
not define operator<<(ostream&, long long) overloads.


[SVN r10095]
2001-05-11 17:04:56 +00:00
07505c76f8 Preprocessor fix for VC6 + STLPort 4.1b6
[SVN r10087]
2001-05-11 10:47:57 +00:00
fda46f9780 HP-UX needs special attention because ULONG_LONG_MAX is not fully usable
[SVN r10080]
2001-05-09 21:07:20 +00:00
125bf3351f gcc on HP-UX doesn't have WCHAR_MIN and WCHAR_MAX
[SVN r10068]
2001-05-08 18:15:32 +00:00
e3702f3abc int64_t may not be defined on HP-UX when using gcc
[SVN r10067]
2001-05-08 18:14:14 +00:00
c54da75efb Fixed more wchar_t problems
[SVN r10058]
2001-05-08 11:11:30 +00:00
2dd1bee693 add HP-UX workaround
[SVN r10051]
2001-05-07 21:21:13 +00:00
949134726f fix the fix for SGI MIPSpro with STLport
[SVN r10008]
2001-05-03 11:57:57 +00:00
b3f587b9f7 IRIX doesn't have WCHAR_MIN and WCHAR_MAX, either
[SVN r10005]
2001-05-02 16:18:08 +00:00
215b4d8ee7 compactify John Maddock's fix for Borland C++ / WCHAR_MIN, WCHAR_MAX
[SVN r10004]
2001-05-02 15:44:02 +00:00
976c5e6572 Fix for Borland C++ and wchar_t
[SVN r10001]
2001-05-02 10:58:30 +00:00
0424bb266e use Boost.Test
test wchar_t
output a message when int64_t is not available


[SVN r9998]
2001-04-30 13:38:23 +00:00
33abcf7250 use BOOST_STATIC_CONSTANT
define static member constants
add wchar_t specialization


[SVN r9997]
2001-04-30 13:36:05 +00:00
12 changed files with 404 additions and 1330 deletions

View File

@ -1,78 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Header boost/cstdint.hpp</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Header
boost/cstdint.hpp&nbsp;</h1>
<p>The header <code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a></code>
provides the typedef's useful for
writing portable code that requires certain integer widths. All typedef's are in namespace boost.</p>
<p>The specifications are based on the ISO/IEC 9899:1999 C Language standard
header &lt;stdint.h&gt;.&nbsp; The 64-bit types required by the C standard are not
required in the boost header, and may not be supplied in all implementations,
because <code>long long</code> is not [yet] included in the C++ standard.</p>
<p>See <a href="cstdint_test.cpp">cstdint_test.cpp</a> for a test program.</p>
<h2>Exact-width integer types</h2>
<p>The typedef <code>int#_t</code>, with # replaced by the width, designates a
signed integer type of exactly # bits; <code>int8_t</code> denotes an 8-bit
signed integer type.&nbsp; Similarly, the typedef <code>uint#_t</code>
designates and unsigned integer type of exactly # bits.</p>
<p>These types are optional. However, if an implementation provides integer
types with widths of 8, 16, 32, or 64 bits, it shall define the corresponding
typedef names.</p>
<h2>Minimum-width integer types</h2>
<p>The typedef <code>int_least#_t</code>, with # replaced by the width,&nbsp;
designates a signed integer type with a width of at least # bits, such that no
signed integer type with lesser size has at least the specified width. Thus, <code>int_least32_t</code>
denotes a signed integer type with a width of at least 32 bits. Similarly, the
typedef name <code>uint_least#_t</code> designates an unsigned integer type with
a width of at least # bits, such that no unsigned integer type with lesser size
has at least the specified width.</p>
<p>Required minimum-width integer types:</p>
<ul>
<li><code>int_least8_t</code></li>
<li><code>int_least16_t</code></li>
<li><code>int_least32_t</code></li>
<li><code>uint_least8_t</code></li>
<li><code>uint_least16_t</code></li>
<li><code>uint_least32_t</code></li>
</ul>
<p>All other minimum-width integer types are optional.</p>
<h2>Fastest minimum-width integer types</h2>
<p>The typedef <code>int_fast#_t</code>, with # replaced by the width,
designates the fastest signed integer type with a width of at least # bits.
Similarly, the typedef name <code>uint_fast#_t</code> designates the fastest
unsigned integer type with a width of at least # bits.</p>
<p>There is no guarantee that these types are fastest for all purposes.&nbsp; In
any case, however, they satisfy&nbsp; the signedness and width requirements.</p>
<p>Required fastest minimum-width integer types:</p>
<ul>
<li><code>int_fast8_t</code></li>
<li><code>int_fast16_t</code></li>
<li><code>int_fast32_t</code></li>
<li><code>uint_fast8_t</code></li>
<li><code>uint_fast16_t</code></li>
<li><code>uint_fast32_t</code></li>
</ul>
<p>All other fastest minimum-width integer types are optional.</p>
<h2>Greatest-width integer types</h2>
<p>The typedef <code>intmax_t </code>designates a signed integer type capable of
representing any value of any signed integer type.</p>
<p>The typedef <code>uintmax_t</code> designates an unsigned integer type
capable of representing any value of any unsigned integer type.</p>
<p>These types are required.</p>
<hr>
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->10 Feb 2001<!--webbot bot="Timestamp" endspan i-checksum="14373" -->
</p>
<p>&nbsp;</p>
</body>
</html>

View File

@ -1,227 +0,0 @@
// boost cstdint.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 2000. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
// 28 Jun 00 Initial version
#include <cassert>
#include <iostream>
#include <boost/cstdint.hpp>
//
// macros should not be defined by default:
//
#ifdef INT8_C
#error header incorrectly implemented
#endif
//
// now define the macros:
//
#define __STDC_CONSTANT_MACROS
#include <boost/cstdint.hpp>
#ifdef NDEBUG
#error This test makes no sense with NDEBUG defined
#endif
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
// the following class is designed to verify
// that the various INTXX_C macros can be used
// in integral constant expressions:
//
struct integral_constant_checker
{
static const boost::int8_t int8 = INT8_C(-127);
static const boost::int_least8_t int_least8 = INT8_C(-127);
static const boost::int_fast8_t int_fast8 = INT8_C(-127);
static const boost::uint8_t uint8 = UINT8_C(255);
static const boost::uint_least8_t uint_least8 = UINT8_C(255);
static const boost::uint_fast8_t uint_fast8 = UINT8_C(255);
static const boost::int16_t int16 = INT16_C(-32767);
static const boost::int_least16_t int_least16 = INT16_C(-32767);
static const boost::int_fast16_t int_fast16 = INT16_C(-32767);
static const boost::uint16_t uint16 = UINT16_C(65535);
static const boost::uint_least16_t uint_least16 = UINT16_C(65535);
static const boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
static const boost::int32_t int32 = INT32_C(-2147483647);
static const boost::int_least32_t int_least32 = INT32_C(-2147483647);
static const boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
static const boost::uint32_t uint32 = UINT32_C(4294967295);
static const boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
static const boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
static void check();
};
void integral_constant_checker::check()
{
assert( int8 == -127 );
assert( int_least8 == -127 );
assert( int_fast8 == -127 );
assert( uint8 == 255u );
assert( uint_least8 == 255u );
assert( uint_fast8 == 255u );
assert( int16 == -32767 );
assert( int_least16 == -32767 );
assert( int_fast16 == -32767 );
assert( uint16 == 65535u );
assert( uint_least16 == 65535u );
assert( uint_fast16 == 65535u );
assert( int32 == -2147483647 );
assert( int_least32 == -2147483647 );
assert( int_fast32 == -2147483647 );
assert( uint32 == 4294967295u );
assert( uint_least32 == 4294967295u );
assert( uint_fast32 == 4294967295u );
}
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
// the following function simply verifies that the type
// of an integral constant is correctly defined:
//
#ifdef __BORLANDC__
#pragma option -w-8008
#pragma option -w-8066
#endif
template <class T1, class T2>
void integral_constant_type_check(T1, T2)
{
//
// the types T1 and T2 may not be exactly
// the same type, but they should be the
// same size and signedness. We could use
// numeric_limits to verify this, but
// numeric_limits implementations currently
// vary too much, or are incomplete or missing.
//
assert(sizeof(T1) == sizeof(T2));
T1 t1 = -1;
T2 t2 = -1;
assert(t1 == t2);
if(t1 >= 0)
assert(t2 >= 0);
else
assert(t2 < 0);
}
int main()
{
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
integral_constant_checker::check();
#endif
//
// verify the types of the integral constants:
//
integral_constant_type_check(boost::int8_t(0), INT8_C(0));
integral_constant_type_check(boost::uint8_t(0), UINT8_C(0));
integral_constant_type_check(boost::int16_t(0), INT16_C(0));
integral_constant_type_check(boost::uint16_t(0), UINT16_C(0));
integral_constant_type_check(boost::int32_t(0), INT32_C(0));
integral_constant_type_check(boost::uint32_t(0), UINT32_C(0));
#ifndef BOOST_NO_INT64_T
integral_constant_type_check(boost::int64_t(0), INT64_C(0));
integral_constant_type_check(boost::uint64_t(0), UINT64_C(0));
#endif
//
boost::int8_t int8 = INT8_C(-127);
boost::int_least8_t int_least8 = INT8_C(-127);
boost::int_fast8_t int_fast8 = INT8_C(-127);
boost::uint8_t uint8 = UINT8_C(255);
boost::uint_least8_t uint_least8 = UINT8_C(255);
boost::uint_fast8_t uint_fast8 = UINT8_C(255);
boost::int16_t int16 = INT16_C(-32767);
boost::int_least16_t int_least16 = INT16_C(-32767);
boost::int_fast16_t int_fast16 = INT16_C(-32767);
boost::uint16_t uint16 = UINT16_C(65535);
boost::uint_least16_t uint_least16 = UINT16_C(65535);
boost::uint_fast16_t uint_fast16 = UINT16_C(65535);
boost::int32_t int32 = INT32_C(-2147483647);
boost::int_least32_t int_least32 = INT32_C(-2147483647);
boost::int_fast32_t int_fast32 = INT32_C(-2147483647);
boost::uint32_t uint32 = UINT32_C(4294967295);
boost::uint_least32_t uint_least32 = UINT32_C(4294967295);
boost::uint_fast32_t uint_fast32 = UINT32_C(4294967295);
#ifndef BOOST_NO_INT64_T
boost::int64_t int64 = INT64_C(-9223372036854775807);
boost::int_least64_t int_least64 = INT64_C(-9223372036854775807);
boost::int_fast64_t int_fast64 = INT64_C(-9223372036854775807);
boost::uint64_t uint64 = UINT64_C(18446744073709551615);
boost::uint_least64_t uint_least64 = UINT64_C(18446744073709551615);
boost::uint_fast64_t uint_fast64 = UINT64_C(18446744073709551615);
boost::intmax_t intmax = INTMAX_C(-9223372036854775807);
boost::uintmax_t uintmax = UINTMAX_C(18446744073709551615);
#else
boost::intmax_t intmax = INTMAX_C(-2147483647);
boost::uintmax_t uintmax = UINTMAX_C(4294967295);
#endif
assert( int8 == -127 );
assert( int_least8 == -127 );
assert( int_fast8 == -127 );
assert( uint8 == 255u );
assert( uint_least8 == 255u );
assert( uint_fast8 == 255u );
assert( int16 == -32767 );
assert( int_least16 == -32767 );
assert( int_fast16 == -32767 );
assert( uint16 == 65535u );
assert( uint_least16 == 65535u );
assert( uint_fast16 == 65535u );
assert( int32 == -2147483647 );
assert( int_least32 == -2147483647 );
assert( int_fast32 == -2147483647 );
assert( uint32 == 4294967295u );
assert( uint_least32 == 4294967295u );
assert( uint_fast32 == 4294967295u );
#ifndef BOOST_NO_INT64_T
assert( int64 == INT64_C(-9223372036854775807) );
assert( int_least64 == INT64_C(-9223372036854775807) );
assert( int_fast64 == INT64_C(-9223372036854775807) );
assert( uint64 == UINT64_C(18446744073709551615) );
assert( uint_least64 == UINT64_C(18446744073709551615) );
assert( uint_fast64 == UINT64_C(18446744073709551615) );
assert( intmax == INT64_C(-9223372036854775807) );
assert( uintmax == UINT64_C(18446744073709551615) );
#else
assert( intmax == -2147483647 );
assert( uintmax == 4294967295u );
#endif
std::cout << "OK\n";
return 0;
}
//
// now verify that constant macros get undef'ed correctly:
//
#undef __STDC_CONSTANT_MACROS
#include <boost/cstdint.hpp>
#ifdef INT8_C
#error boost/cstdint.hpp not correctly defined
#endif

View File

@ -6,9 +6,10 @@
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// See http://www.boost.org/libs/integer for documentation.
// Revision History
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer)
// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer)
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer)
@ -24,9 +25,21 @@
#include <boost/config.hpp>
#ifdef BOOST_SYSTEM_HAS_STDINT_H
#ifdef BOOST_HAS_STDINT_H
# include <stdint.h> // implementation artifact; not part of interface
// The following #include is an implementation artifact; not part of interface.
# ifdef __hpux
// HP-UX has a vaguely nice <stdint.h> in a non-standard location
# include <inttypes.h>
# ifdef __STDC_32_MODE__
// this is triggered with GCC, because it defines __cplusplus < 199707L
# define BOOST_NO_INT64_T
# endif
# elif defined(__FreeBSD__) || defined(__IBMCPP__)
# include <inttypes.h>
# else
# include <stdint.h>
# endif
namespace boost
{
@ -68,11 +81,57 @@ namespace boost
} // namespace boost
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4)
// FreeBSD has an <inttypes.h> that contains much of what we need
# include <inttypes.h>
#else // BOOST_SYSTEM_HAS_STDINT_H
namespace boost {
using ::int8_t;
typedef int8_t int_least8_t;
typedef int8_t int_fast8_t;
using ::uint8_t;
typedef uint8_t uint_least8_t;
typedef uint8_t uint_fast8_t;
using ::int16_t;
typedef int16_t int_least16_t;
typedef int16_t int_fast16_t;
using ::uint16_t;
typedef uint16_t uint_least16_t;
typedef uint16_t uint_fast16_t;
using ::int32_t;
typedef int32_t int_least32_t;
typedef int32_t int_fast32_t;
using ::uint32_t;
typedef uint32_t uint_least32_t;
typedef uint32_t uint_fast32_t;
# ifndef BOOST_NO_INT64_T
# include <limits.h> // implementation artifact; not part of interface
using ::int64_t;
typedef int64_t int_least64_t;
typedef int64_t int_fast64_t;
using ::uint64_t;
typedef uint64_t uint_least64_t;
typedef uint64_t uint_fast64_t;
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
# else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# endif
} // namespace boost
#else // BOOST_HAS_STDINT_H
# include <boost/limits.hpp> // implementation artifact; not part of interface
namespace boost
@ -102,12 +161,29 @@ namespace boost
// 16-bit types -----------------------------------------------------------//
# if USHRT_MAX == 0xffff
# if defined(__crayx1)
// The Cray X1 has a 16-bit short, however it is not recommend
// for use in performance critical code.
typedef short int16_t;
typedef short int_least16_t;
typedef int int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned int uint_fast16_t;
# else
typedef short int16_t;
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# endif
# elif (USHRT_MAX == 0xffffffff) && defined(CRAY)
// no 16-bit types on Cray:
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
@ -134,9 +210,18 @@ namespace boost
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)
# if (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# if defined(BOOST_HAS_LONG_LONG) && \
!defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
# if defined(__hpux)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL)
// 2**64 - 1
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef long long int64_t;
@ -145,9 +230,7 @@ namespace boost
typedef unsigned long long uint64_t;
typedef unsigned long long uint_least64_t;
typedef unsigned long long uint_fast64_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
@ -162,9 +245,9 @@ namespace boost
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
# elif defined(BOOST_HAS_MS_INT64)
//
// we have Borland/Microsoft __int64:
// we have Borland/Intel/Microsoft __int64:
//
typedef __int64 intmax_t;
typedef unsigned __int64 uintmax_t;
@ -183,7 +266,7 @@ namespace boost
} // namespace boost
#endif // BOOST_SYSTEM_HAS_STDINT_H
#endif // BOOST_HAS_STDINT_H
#endif // BOOST_CSTDINT_HPP
@ -198,15 +281,17 @@ __STDC_CONSTANT_MACROS is defined.
Undefine the macros if __STDC_CONSTANT_MACROS is
not defined and the macros are (cf <cassert>).
Added 23rd September (John Maddock).
Added 23rd September 2000 (John Maddock).
Modified 11th September 2001 to be excluded when
BOOST_HAS_STDINT_H is defined (John Maddock).
******************************************************/
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED)
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
# if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
# if defined(BOOST_HAS_MS_INT64)
//
// Borland/Microsoft compilers have width specific suffixes:
// Borland/Intel/Microsoft compilers have width specific suffixes:
//
# define INT8_C(value) value##i8
# define INT16_C(value) value##i16
@ -253,14 +338,20 @@ Added 23rd September (John Maddock).
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)
# if (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# if defined(BOOST_HAS_LONG_LONG) && \
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
# if defined(__hpux)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || \
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
@ -282,7 +373,7 @@ Added 23rd September (John Maddock).
# endif // Borland/Microsoft specific width suffixes
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS)
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H)
//
// undef all the macros:
//
@ -299,3 +390,6 @@ Added 23rd September (John Maddock).
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.

View File

@ -6,9 +6,10 @@
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// See http://www.boost.org/libs/integer for documentation.
// Revision History
// 22 Sep 01 Added value-based integer templates. (Daryle Walker)
// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (John Maddock)
// 30 Jul 00 Add typename syntax fix (Jens Maurer)
// 28 Aug 99 Initial version
@ -16,7 +17,10 @@
#ifndef BOOST_INTEGER_HPP
#define BOOST_INTEGER_HPP
#include <boost/limits.hpp>
#include <boost/integer_fwd.hpp> // self include
#include <boost/integer_traits.hpp> // for boost::integer_traits
#include <boost/limits.hpp> // for std::numeric_limits
namespace boost
{
@ -75,11 +79,51 @@ namespace boost
// int_fast_t<> works correctly for unsigned too, in spite of the name.
};
// The same dispatching technique can be used to select types based on
// values. That will be added once boost::integer_traits is available.
// integer templates specifying extreme value ----------------------------//
// signed
template< long MaxValue > // maximum value to require support
struct int_max_value_t
{
typedef typename int_least_helper
<
(MaxValue <= integer_traits<long>::const_max) +
(MaxValue <= integer_traits<int>::const_max) +
(MaxValue <= integer_traits<short>::const_max) +
(MaxValue <= integer_traits<signed char>::const_max)
>::least least;
typedef typename int_fast_t<least>::fast fast;
};
template< long MinValue > // minimum value to require support
struct int_min_value_t
{
typedef typename int_least_helper
<
(MinValue >= integer_traits<long>::const_min) +
(MinValue >= integer_traits<int>::const_min) +
(MinValue >= integer_traits<short>::const_min) +
(MinValue >= integer_traits<signed char>::const_min)
>::least least;
typedef typename int_fast_t<least>::fast fast;
};
// unsigned
template< unsigned long Value > // maximum value to require support
struct uint_value_t
{
typedef typename int_least_helper
<
5 +
(Value <= integer_traits<unsigned long>::const_max) +
(Value <= integer_traits<unsigned int>::const_max) +
(Value <= integer_traits<unsigned short>::const_max) +
(Value <= integer_traits<unsigned char>::const_max)
>::least least;
typedef typename int_fast_t<least>::fast fast;
};
} // namespace boost
#endif // BOOST_INTEGER_HPP

View File

@ -0,0 +1,154 @@
// Boost integer_fwd.hpp header file ---------------------------------------//
// (C) Copyright boost.org 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_FWD_HPP
#define BOOST_INTEGER_FWD_HPP
#include <climits> // for UCHAR_MAX, etc.
#include <cstddef> // for std::size_t
#include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
#include <boost/limits.hpp> // for std::numeric_limits
namespace boost
{
// From <boost/cstdint.hpp> ------------------------------------------------//
// Only has typedefs or using statements, with #conditionals
// From <boost/integer_traits.hpp> -----------------------------------------//
template < class T >
class integer_traits;
template < >
class integer_traits< bool >;
template < >
class integer_traits< char >;
template < >
class integer_traits< signed char >;
template < >
class integer_traits< unsigned char >;
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template < >
class integer_traits< wchar_t >;
#endif
template < >
class integer_traits< short >;
template < >
class integer_traits< unsigned short >;
template < >
class integer_traits< int >;
template < >
class integer_traits< unsigned int >;
template < >
class integer_traits< long >;
template < >
class integer_traits< unsigned long >;
#ifdef ULLONG_MAX
template < >
class integer_traits< long long >;
template < >
class integer_traits< unsigned long long >;
#endif
// From <boost/integer.hpp> ------------------------------------------------//
template < typename LeastInt >
struct int_fast_t;
template< int Bits >
struct int_t;
template< int Bits >
struct uint_t;
template< long MaxValue >
struct int_max_value_t;
template< long MinValue >
struct int_min_value_t;
template< unsigned long Value >
struct uint_value_t;
// From <boost/integer/integer_mask.hpp> -----------------------------------//
template < std::size_t Bit >
struct high_bit_mask_t;
template < std::size_t Bits >
struct low_bits_mask_t;
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
#if USHRT_MAX > UCHAR_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned short>::digits >;
#endif
#if UINT_MAX > USHRT_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned int>::digits >;
#endif
#if ULONG_MAX > UINT_MAX
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned long>::digits >;
#endif
// From <boost/integer/static_log2.hpp> ------------------------------------//
template < unsigned long Value >
struct static_log2;
template < >
struct static_log2< 0ul >;
// From <boost/integer/static_min_max.hpp> ---------------------------------//
template < long Value1, long Value2 >
struct static_signed_min;
template < long Value1, long Value2 >
struct static_signed_max;
template < unsigned long Value1, unsigned long Value2 >
struct static_unsigned_min;
template < unsigned long Value1, unsigned long Value2 >
struct static_unsigned_max;
} // namespace boost
#endif // BOOST_INTEGER_FWD_HPP

View File

@ -15,14 +15,20 @@
* Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
*/
// See http://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_TRAITS_HPP
#define BOOST_INTEGER_TRAITS_HPP
#include <boost/config.hpp>
#include <boost/limits.hpp>
// This is an implementation detail and not part of the interface
// These are an implementation detail and not part of the interface
#include <limits.h>
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR)
#include <wchar.h>
#endif
namespace boost {
@ -30,11 +36,7 @@ template<class T>
class integer_traits : public std::numeric_limits<T>
{
public:
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool is_integral = false;
#else
enum { is_integral = false };
#endif
BOOST_STATIC_CONSTANT(bool, is_integral = false);
};
namespace detail {
@ -42,18 +44,23 @@ template<class T, T min_val, T max_val>
class integer_traits_base
{
public:
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
static const bool is_integral = true;
static const T const_min = min_val;
static const T const_max = max_val;
#else
enum {
is_integral = true,
const_min = min_val,
const_max = max_val
};
#endif
BOOST_STATIC_CONSTANT(bool, is_integral = true);
BOOST_STATIC_CONSTANT(T, const_min = min_val);
BOOST_STATIC_CONSTANT(T, const_max = max_val);
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
template<class T, T min_val, T max_val>
const bool integer_traits_base<T, min_val, max_val>::is_integral;
template<class T, T min_val, T max_val>
const T integer_traits_base<T, min_val, max_val>::const_min;
template<class T, T min_val, T max_val>
const T integer_traits_base<T, min_val, max_val>::const_max;
#endif
} // namespace detail
template<>
@ -80,7 +87,36 @@ class integer_traits<unsigned char>
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
{ };
// What about wchar_t ?
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<>
class integer_traits<wchar_t>
: public std::numeric_limits<wchar_t>,
#if defined(WCHAR_MIN) && defined(WCHAR_MAX)
public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
// No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
public detail::integer_traits_base<wchar_t, 0, 0xffff>
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
|| (defined __APPLE__)\
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
// - SGI MIPSpro with native library
// - gcc 3.x on HP-UX
// - Mac OS X with native library
// - gcc on FreeBSD
public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
#elif defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 2) && !defined(__SGI_STL_PORT)
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as unsigned int.
// - gcc 2.95.x on HP-UX
// (also, std::numeric_limits<wchar_t> appears to return the wrong values).
public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
#else
#error No WCHAR_MIN and WCHAR_MAX present, please adjust integer_traits<> for your compiler.
#endif
{ };
#endif // BOOST_NO_INTRINSIC_WCHAR_T
template<>
class integer_traits<short>
@ -118,41 +154,64 @@ class integer_traits<unsigned long>
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
{ };
#ifdef ULLONG_MAX
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LLONG_MIN, LLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULLONG_MAX>
{ };
#elif defined(ULONG_LONG_MAX)
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>
{ };
class integer_traits<long long> : public std::numeric_limits<long long>, public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
{ };
#elif defined(ULONGLONG_MAX)
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
{ };
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, -_LLONG_MAX - _C2, _LLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, _ULLONG_MAX>
{ };
#endif
#endif
} // namespace boost
#endif /* BOOST_INTEGER_TRAITS_HPP */

View File

@ -1,272 +0,0 @@
// boost stdint.h header file ---------------------------------------------//
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// NOTE WELL: This is an implementation of the ISO C Standard (1999) stdint.h
// header. C++ programs are advised to use <boost/cstdint.hpp> rather than
// this header.
// NOTE OF OBSOLESCENCE: In general, this header file cannot detect
// whether the current translation unit somewhere includes ISO C99
// <stdint.h> or not. For example, in case BOOST_SYSTEM_HAS_STDINT_H
// is not defined and ISO C99 <stdint.h> has been included before,
// this file will re-define ISO C99 reserved file-scope identifiers
// such as int8_t (see ISO C99 7.1.3 and 7.18). Defining the macro
// BOOST_SYSTEM_HAS_STDINT_H is not sufficient in general, in
// particular if a partly conformant <stdint.h> header is available
// on the platform, e.g. Comeau C++ with GNU glibc 2.1.2.
//
// In order to avoid incompatibilities with ISO C99, this header
// should not be used at all, and it may be deleted in the future.
// C++ programs which require ISO C99 <stdint.h> functionality are
// strongly advised to use <boost/cstdint.hpp> instead, which
// provides <stdint.h> names in namespace boost, e.g. boost::int8_t.
// Revision History
// 12 Nov 00 obsoleted (Jens Maurer)
// 23 Sep 00 INTXX_C support added (John Maddock)
// 22 Sep 00 64-bit support for Borland & Microsoft compilers (John Maddock)
// 8 Aug 99 Initial version (Beman Dawes)
#ifndef BOOST_STDINT_H
#define BOOST_STDINT_H
#include <boost/config.hpp>
#ifdef BOOST_SYSTEM_HAS_STDINT_H
#include <stdint.h>
#else
#include <limits.h> // implementation artifact; not part of interface
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
// platforms. For other systems, they will have to be hand tailored.
//
// Because the fast types are assumed to be the same as the undecorated types,
// it may be possible to hand tailor a more efficient implementation. Such
// an optimization may be illusionary; on the Intel x86-family 386 on, for
// example, byte arithmetic and load/stores are as fast as "int" sized ones.
// 8-bit types -------------------------------------------------------------//
# if UCHAR_MAX == 0xff
typedef signed char int8_t;
typedef signed char int_least8_t;
typedef signed char int_fast8_t;
typedef unsigned char uint8_t;
typedef unsigned char uint_least8_t;
typedef unsigned char uint_fast8_t;
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
// 16-bit types ------------------------------------------------------------//
# if USHRT_MAX == 0xffff
typedef short int16_t;
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
// 32-bit types ------------------------------------------------------------//
# if UINT_MAX == 0xffffffff
typedef int int32_t;
typedef int int_least32_t;
typedef int int_fast32_t;
typedef unsigned int uint32_t;
typedef unsigned int uint_least32_t;
typedef unsigned int uint_fast32_t;
# elif ULONG_MAX == 0xffffffff
typedef long int32_t;
typedef long int_least32_t;
typedef long int_fast32_t;
typedef unsigned long uint32_t;
typedef unsigned long uint_least32_t;
typedef unsigned long uint_fast32_t;
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
// 64-bit types + intmax_t and uintmax_t -----------------------------------//
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
// 2**64 - 1
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef long long int64_t;
typedef long long int_least64_t;
typedef long long int_fast64_t;
typedef unsigned long long uint64_t;
typedef unsigned long long uint_least64_t;
typedef unsigned long long uint_fast64_t;
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
typedef long intmax_t;
typedef unsigned long uintmax_t;
typedef long int64_t;
typedef long int_least64_t;
typedef long int_fast64_t;
typedef unsigned long uint64_t;
typedef unsigned long uint_least64_t;
typedef unsigned long uint_fast64_t;
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
//
// we have Borland/Microsoft __int64:
//
typedef __int64 intmax_t;
typedef unsigned __int64 uintmax_t;
typedef __int64 int64_t;
typedef __int64 int_least64_t;
typedef __int64 int_fast64_t;
typedef unsigned __int64 uint64_t;
typedef unsigned __int64 uint_least64_t;
typedef unsigned __int64 uint_fast64_t;
# else // assume no 64-bit integers
#define BOOST_NO_INT64_T
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# endif
#endif // BOOST_SYSTEM_HAS_STDINT_H not defined
#endif // BOOST_STDINT_H
/****************************************************
Macro definition section:
Define various INTXX_C macros only if
__STDC_CONSTANT_MACROS is defined.
Undefine the macros if __STDC_CONSTANT_MACROS is
not defined and the macros are (cf <cassert>).
Added 23rd September (John Maddock).
******************************************************/
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED)
#define BOOST__STDC_CONSTANT_MACROS_DEFINED
#if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
//
// Borland/Microsoft compilers have width specific suffixes:
//
#define INT8_C(value) value##i8
#define INT16_C(value) value##i16
#define INT32_C(value) value##i32
#define INT64_C(value) value##i64
#ifdef __BORLANDC__
// Borland bug: appending ui8 makes the type
// a signed char!!!!
#define UINT8_C(value) static_cast<unsigned char>(value##u)
#else
#define UINT8_C(value) value##ui8
#endif
#define UINT16_C(value) value##ui16
#define UINT32_C(value) value##ui32
#define UINT64_C(value) value##ui64
#define INTMAX_C(value) value##i64
#define UINTMAX_C(value) value##ui64
#else
// do it the old fashioned way:
// 8-bit types -------------------------------------------------------------//
# if UCHAR_MAX == 0xff
#define INT8_C(value) static_cast<int8_t>(value)
#define UINT8_C(value) static_cast<uint8_t>(value##u)
# endif
// 16-bit types ------------------------------------------------------------//
# if USHRT_MAX == 0xffff
#define INT16_C(value) static_cast<int16_t>(value)
#define UINT16_C(value) static_cast<uint16_t>(value##u)
# endif
// 32-bit types ------------------------------------------------------------//
# if UINT_MAX == 0xffffffff
#define INT32_C(value) value
#define UINT32_C(value) value##u
# elif ULONG_MAX == 0xffffffff
#define INT32_C(value) value##L
#define UINT32_C(value) value##uL
# endif
// 64-bit types + intmax_t and uintmax_t -----------------------------------//
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
#define INT64_C(value) value##LL
#define UINT64_C(value) value##uLL
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
# elif ULONG_MAX != 0xffffffff
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
#define INT64_C(value) value##L
#define UINT64_C(value) value##uL
# else
# error defaults not correct; you must hand modify boost/stdint.h
# endif
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
//
// we have Borland/Microsoft __int64:
//
#define INT64_C(value) value##i64
#define UINT64_C(value) value##ui64
# endif
#ifdef BOOST_NO_INT64_T
#define INTMAX_C(value) INT32_C(value)
#define UINTMAX_C(value) UINT32_C(value)
#else
#define INTMAX_C(value) INT64_C(value)
#define UINTMAX_C(value) UINT64_C(value)
#endif
#endif // Borland/MS specific
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS)
//
// undef all the macros:
//
#undef INT8_C
#undef INT16_C
#undef INT32_C
#undef INT64_C
#undef UINT8_C
#undef UINT16_C
#undef UINT32_C
#undef UINT64_C
#undef INTMAX_C
#undef UINTMAX_C
#endif // constant macros

View File

@ -1,98 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Boost Integer Library</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table border="1" bgcolor="#007F7F" cellpadding="2">
<tr>
<td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="#FFFFFF"><big>Home </big></font></a></td>
<td><a href="../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries </big></font></a></td>
<td><a href="../../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People </big></font></a></td>
<td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ </big></font></a></td>
<td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More </big></font></a></td>
</tr>
</table>
<h1>Boost Integer Library</h1>
<table border="1" cellpadding="5">
<tr>
<td align="center"><b><i>Header / Docs</i></b></td>
<td align="center"><b><i>Contents</i></b></td>
<td align="center"><b><i>Use</i></b></td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;<br>
</a></code><a href="cstdint.htm"><br>
documentation</a>
</td>
<td valign="top">Typedef's based on the 1999 C Standard header &lt;<code>stdint.h&gt;</code>, wrapped in namespace boost.
This implementation may #include the compiler
supplied &lt;<code>stdint.h&gt;</code>, if present. </td>
<td valign="top">Supplies typedefs for standard integer types such as <code> int32_t</code> or <code>uint_least16_t</code>.
Use in preference to &lt;<code>stdint.h&gt;</code>
for enhanced portability. Furthermore, all names are safely placed in the boost namespace.</td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer_traits.hpp">&lt;boost/integer_traits.hpp&gt;</a></code><br>
<br>
<a href="integer_traits.html">documentation</a>
</td>
<td valign="top">Template class <code>boost::integer_traits</code>, derived from <code>std::numeric_limits</code>.&nbsp;
Adds <code>const_min</code> and <code>const_max</code> members.</td>
<td valign="top">Use to obtain the characteristics of a known integer type.</td>
</tr>
<tr>
<td align="center"><code><a href="../../boost/integer.hpp">&lt;boost/integer.hpp&gt;</a><br>
<br>
</code><a href="integer.htm">documentation</a></td>
<td valign="top">Templates for integer type selection based on properties such as
maximum value or number of bits.</td>
<td valign="top">Use to select the type an integer when some property such as maximum value or number of bits is known.
Useful for generic programming. </td>
</tr>
</table>
<h2>Rationale</h2>
<p>The organization of boost integer headers and classes is designed to take
advantage of <code>&lt;stdint.h&gt;</code> types from the 1999 C standard
without resorting to undefined behavior in terms of
the 1998 C++ standard.&nbsp; The header <code>&lt;boost/cstdint.hpp&gt;</code>
makes the standard integer types safely available in namespace boost without placing any names in namespace std. As always, the intension is to complement rather than
compete with the C++ Standard Library.&nbsp; Should some future C++ standard
include <code>&lt;stdint.h&gt;</code> and <code>&lt;cstdint&gt;</code>, then <code>&lt;boost/cstdint.hpp&gt;</code>
will continue to function, but will become redundant and may be safely deprecated.</p>
<p>Because these are boost headers, their names conform to boost header naming
conventions rather than C++ Standard Library header naming conventions.
<h2>Caveat emptor</h2>
<p>As an
implementation artifact, certain C &lt;limits.h&gt; macro names may possibly be
visible to users of &lt;boost/cstdint.hpp&gt;.&nbsp; Don't use these macros; they are not part of
any Boost specified interface.&nbsp;
Use boost:: integer_traits&lt;&gt; or std::numeric_limits&lt;&gt; instead.</p>
<p>
As another implementation artifact, certain C
<code>&lt;stdint.h&gt;</code> typedef names may possibly be visible in the
global namespace to users of <code>&lt;boost/cstdint.hpp&gt;</code>.
Don't use these names, they are not part of any Boost specified
interface. Use the respective names in namespace <code>boost</code>
instead.
<hr>
<p>Revised: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %b %Y" startspan -->10 Feb 2001<!--webbot bot="Timestamp" endspan i-checksum="14373" -->
</p>
</body>
</html>

View File

@ -1,112 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Integer Type Selection Templates</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Integer
Type Selection Templates</h1>
<p>The <code><a href="../../boost/integer.hpp">&lt;boost/integer.hpp&gt;</a></code>
type selection templates allow integer types to be selected based on desired
characteristics such as number of bits or maximum value.&nbsp; This facility is
particularly useful for solving generic programming problems.</p>
<p>The templates <b>int_t&lt;&gt;</b> and <b>uint_t&lt;&gt;</b> supply typedefs <b>least</b>
and <b>fast</b>.&nbsp; The <b>least</b> type be the smallest type which holds at
least the number of bits (including sign) specified. The <b>fast</b> type will
be at least as large as the <b>least</b> type, but may possible be larger.&nbsp;
There is no guarantee that the <b>fast</b> type will actually be faster than
other possible types.</p>
<h2>Alternative</h2>
<p>If the number of bits required is known beforehand, it may be more
appropriate to use the types supplied in <code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a></code>.</p>
<h2>Synopsis</h2>
<blockquote>
<pre>namespace boost
{
// fast integers from least integers
// int_fast_t&lt;&gt; works correctly for unsigned too, in spite of the name.
template&lt; typename LeastInt &gt; // Required: LeastInt is integral type, not bool
struct int_fast_t { typedef LeastInt fast; }; // implementations may specialize
// signed
template&lt; int Bits &gt; // bits (including sign) required, 0-32 valid
struct int_t
{
typedef <i>implementation-supplied</i> least;
typedef int_fast_t&lt;least&gt;::fast fast;
};
// unsigned
template&lt; int Bits &gt; // bits required, 0-32 valid
struct uint_t
{
typedef <i>implementation-supplied</i> least;
typedef int_fast_t&lt;least&gt;::fast fast;
// int_fast_t&lt;&gt; works correctly for unsigned too, in spite of the name.
};
} // namespace boost
</pre>
</blockquote>
<p>[Templates to select type based on maximum value are under development.]
</p>
<h2>Example</h2>
<blockquote>
<pre>#include &lt;boost/integer.hpp&gt;
using boost::int_t;
...
int_t&lt;24&gt;::least my_var; </pre>
</blockquote>
<h2>Demonstration Program</h2>
<p>The program <a href="integer_test.cpp">integer_test.cpp</a> is a not very
smart demonstration of the results from instantiating various <b>int_t&lt;&gt;</b>
and <b>uint_t&lt;&gt;</b> examples.</p>
<h2>Rationale</h2>
<p>The rationale for the design of the templates in this header includes:</p>
<ul>
<li>Avoid&nbsp; recursion because of concern about C++'s limited guaranteed
recursion depth (17).</li>
<li>Avoid macros on general principles.</li>
<li>Try to keep the design as simple as possible.</li>
</ul>
<h2>Credits</h2>
<p>The author of the Boost integer type choosing templates is <a href="../../people/beman_dawes.html">Beman
Dawes</a>.&nbsp; He thanks to <a href="../../people/valentin_bonnard.htm"> Valentin Bonnard</a> and
<a href="../../people/kevlin_henney.htm"> Kevlin Henney</a> for sharing their designs for similar templates.</p>
<hr>
<p>Revised&nbsp; August 31, 1999</p>
<p><EFBFBD> Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
and distribute this document is granted provided this copyright notice appears in all
copies. This document is provided &quot;as is&quot; without express or implied warranty,
and with no claim as to its suitability for any purpose.</p>
<p></p>
<p>&nbsp;</p>
</body>
</html>

View File

@ -1,317 +0,0 @@
// boost integer.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
// 31 Aug 99 Initial version
#include <iostream>
#include <boost/integer.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
namespace
{
void test( long ) { std::cout << "long\n"; }
void test( int ) { std::cout << "int\n"; }
void test( short ) { std::cout << "short\n"; }
void test( signed char ) { std::cout << "signed char\n"; }
void test( unsigned long ) { std::cout << "unsigned long\n"; }
void test( unsigned int ) { std::cout << "unsigned int\n"; }
void test( unsigned short ) { std::cout << "unsigned short\n"; }
void test( unsigned char ) { std::cout << "unsigned char\n"; }
} // unnamed namespace
// just to prove it works, specialize int_fast_t<short> to yield long
namespace boost
{
template<> struct int_fast_t<short> { typedef long fast; };
}
int test_main(int,char**)
{
using boost::int_t;
using boost::uint_t;
#ifdef BOOST_SHOW_TYPES
std::cout << 32 << ' '; test( int_t<32>::least() );
std::cout << 31 << ' '; test( int_t<31>::least() );
std::cout << 30 << ' '; test( int_t<30>::least() );
std::cout << 29 << ' '; test( int_t<29>::least() );
std::cout << 28 << ' '; test( int_t<28>::least() );
std::cout << 27 << ' '; test( int_t<27>::least() );
std::cout << 26 << ' '; test( int_t<26>::least() );
std::cout << 25 << ' '; test( int_t<25>::least() );
std::cout << 24 << ' '; test( int_t<24>::least() );
std::cout << 23 << ' '; test( int_t<23>::least() );
std::cout << 22 << ' '; test( int_t<22>::least() );
std::cout << 21 << ' '; test( int_t<21>::least() );
std::cout << 20 << ' '; test( int_t<20>::least() );
std::cout << 19 << ' '; test( int_t<19>::least() );
std::cout << 18 << ' '; test( int_t<18>::least() );
std::cout << 17 << ' '; test( int_t<17>::least() );
std::cout << 16 << ' '; test( int_t<16>::least() );
std::cout << 15 << ' '; test( int_t<15>::least() );
std::cout << 14 << ' '; test( int_t<14>::least() );
std::cout << 13 << ' '; test( int_t<13>::least() );
std::cout << 12 << ' '; test( int_t<12>::least() );
std::cout << 11 << ' '; test( int_t<11>::least() );
std::cout << 10 << ' '; test( int_t<10>::least() );
std::cout << 9 << ' '; test( int_t<9>::least() );
std::cout << 8 << ' '; test( int_t<8>::least() );
std::cout << 7 << ' '; test( int_t<7>::least() );
std::cout << 6 << ' '; test( int_t<6>::least() );
std::cout << 5 << ' '; test( int_t<5>::least() );
std::cout << 4 << ' '; test( int_t<4>::least() );
std::cout << 3 << ' '; test( int_t<3>::least() );
std::cout << 2 << ' '; test( int_t<2>::least() );
std::cout << 1 << ' '; test( int_t<1>::least() );
std::cout << 0 << ' '; test( int_t<0>::least() );
std::cout << 32 << ' '; test( int_t<32>::fast() );
std::cout << 31 << ' '; test( int_t<31>::fast() );
std::cout << 30 << ' '; test( int_t<30>::fast() );
std::cout << 29 << ' '; test( int_t<29>::fast() );
std::cout << 28 << ' '; test( int_t<28>::fast() );
std::cout << 27 << ' '; test( int_t<27>::fast() );
std::cout << 26 << ' '; test( int_t<26>::fast() );
std::cout << 25 << ' '; test( int_t<25>::fast() );
std::cout << 24 << ' '; test( int_t<24>::fast() );
std::cout << 23 << ' '; test( int_t<23>::fast() );
std::cout << 22 << ' '; test( int_t<22>::fast() );
std::cout << 21 << ' '; test( int_t<21>::fast() );
std::cout << 20 << ' '; test( int_t<20>::fast() );
std::cout << 19 << ' '; test( int_t<19>::fast() );
std::cout << 18 << ' '; test( int_t<18>::fast() );
std::cout << 17 << ' '; test( int_t<17>::fast() );
std::cout << 16 << ' '; test( int_t<16>::fast() );
std::cout << 15 << ' '; test( int_t<15>::fast() );
std::cout << 14 << ' '; test( int_t<14>::fast() );
std::cout << 13 << ' '; test( int_t<13>::fast() );
std::cout << 12 << ' '; test( int_t<12>::fast() );
std::cout << 11 << ' '; test( int_t<11>::fast() );
std::cout << 10 << ' '; test( int_t<10>::fast() );
std::cout << 9 << ' '; test( int_t<9>::fast() );
std::cout << 8 << ' '; test( int_t<8>::fast() );
std::cout << 7 << ' '; test( int_t<7>::fast() );
std::cout << 6 << ' '; test( int_t<6>::fast() );
std::cout << 5 << ' '; test( int_t<5>::fast() );
std::cout << 4 << ' '; test( int_t<4>::fast() );
std::cout << 3 << ' '; test( int_t<3>::fast() );
std::cout << 2 << ' '; test( int_t<2>::fast() );
std::cout << 1 << ' '; test( int_t<1>::fast() );
std::cout << 0 << ' '; test( int_t<0>::fast() );
std::cout << 32 << ' '; test( uint_t<32>::least() );
std::cout << 31 << ' '; test( uint_t<31>::least() );
std::cout << 30 << ' '; test( uint_t<30>::least() );
std::cout << 29 << ' '; test( uint_t<29>::least() );
std::cout << 28 << ' '; test( uint_t<28>::least() );
std::cout << 27 << ' '; test( uint_t<27>::least() );
std::cout << 26 << ' '; test( uint_t<26>::least() );
std::cout << 25 << ' '; test( uint_t<25>::least() );
std::cout << 24 << ' '; test( uint_t<24>::least() );
std::cout << 23 << ' '; test( uint_t<23>::least() );
std::cout << 22 << ' '; test( uint_t<22>::least() );
std::cout << 21 << ' '; test( uint_t<21>::least() );
std::cout << 20 << ' '; test( uint_t<20>::least() );
std::cout << 19 << ' '; test( uint_t<19>::least() );
std::cout << 18 << ' '; test( uint_t<18>::least() );
std::cout << 17 << ' '; test( uint_t<17>::least() );
std::cout << 16 << ' '; test( uint_t<16>::least() );
std::cout << 15 << ' '; test( uint_t<15>::least() );
std::cout << 14 << ' '; test( uint_t<14>::least() );
std::cout << 13 << ' '; test( uint_t<13>::least() );
std::cout << 12 << ' '; test( uint_t<12>::least() );
std::cout << 11 << ' '; test( uint_t<11>::least() );
std::cout << 10 << ' '; test( uint_t<10>::least() );
std::cout << 9 << ' '; test( uint_t<9>::least() );
std::cout << 8 << ' '; test( uint_t<8>::least() );
std::cout << 7 << ' '; test( uint_t<7>::least() );
std::cout << 6 << ' '; test( uint_t<6>::least() );
std::cout << 5 << ' '; test( uint_t<5>::least() );
std::cout << 4 << ' '; test( uint_t<4>::least() );
std::cout << 3 << ' '; test( uint_t<3>::least() );
std::cout << 2 << ' '; test( uint_t<2>::least() );
std::cout << 1 << ' '; test( uint_t<1>::least() );
std::cout << 0 << ' '; test( uint_t<0>::least() );
std::cout << 32 << ' '; test( uint_t<32>::fast() );
std::cout << 31 << ' '; test( uint_t<31>::fast() );
std::cout << 30 << ' '; test( uint_t<30>::fast() );
std::cout << 29 << ' '; test( uint_t<29>::fast() );
std::cout << 28 << ' '; test( uint_t<28>::fast() );
std::cout << 27 << ' '; test( uint_t<27>::fast() );
std::cout << 26 << ' '; test( uint_t<26>::fast() );
std::cout << 25 << ' '; test( uint_t<25>::fast() );
std::cout << 24 << ' '; test( uint_t<24>::fast() );
std::cout << 23 << ' '; test( uint_t<23>::fast() );
std::cout << 22 << ' '; test( uint_t<22>::fast() );
std::cout << 21 << ' '; test( uint_t<21>::fast() );
std::cout << 20 << ' '; test( uint_t<20>::fast() );
std::cout << 19 << ' '; test( uint_t<19>::fast() );
std::cout << 18 << ' '; test( uint_t<18>::fast() );
std::cout << 17 << ' '; test( uint_t<17>::fast() );
std::cout << 16 << ' '; test( uint_t<16>::fast() );
std::cout << 15 << ' '; test( uint_t<15>::fast() );
std::cout << 14 << ' '; test( uint_t<14>::fast() );
std::cout << 13 << ' '; test( uint_t<13>::fast() );
std::cout << 12 << ' '; test( uint_t<12>::fast() );
std::cout << 11 << ' '; test( uint_t<11>::fast() );
std::cout << 10 << ' '; test( uint_t<10>::fast() );
std::cout << 9 << ' '; test( uint_t<9>::fast() );
std::cout << 8 << ' '; test( uint_t<8>::fast() );
std::cout << 7 << ' '; test( uint_t<7>::fast() );
std::cout << 6 << ' '; test( uint_t<6>::fast() );
std::cout << 5 << ' '; test( uint_t<5>::fast() );
std::cout << 4 << ' '; test( uint_t<4>::fast() );
std::cout << 3 << ' '; test( uint_t<3>::fast() );
std::cout << 2 << ' '; test( uint_t<2>::fast() );
std::cout << 1 << ' '; test( uint_t<1>::fast() );
std::cout << 0 << ' '; test( uint_t<0>::fast() );
#endif
long v = 0x7FFFFFFF;
BOOST_TEST( int_t<32>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<31>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<30>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<29>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<28>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<27>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<26>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<25>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<24>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<23>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<22>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<21>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<20>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<19>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<18>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<17>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<16>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<15>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<14>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<13>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<12>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<11>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<10>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<9>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<8>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<7>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<6>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<5>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<4>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<3>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<2>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<1>::least(v) == v ); v >>= 1;
BOOST_TEST( int_t<0>::least(v) == v );
v = 0x7FFFFFFF;
BOOST_TEST( int_t<32>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<31>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<30>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<29>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<28>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<27>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<26>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<25>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<24>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<23>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<22>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<21>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<20>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<19>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<18>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<17>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<16>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<15>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<14>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<13>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<12>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<11>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<10>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<9>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<8>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<7>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<6>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<5>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<4>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<3>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<2>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<1>::fast(v) == v ); v >>= 1;
BOOST_TEST( int_t<0>::fast(v) == v );
unsigned long u = 0xFFFFFFFF;
BOOST_TEST( uint_t<32>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<31>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<30>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<29>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<28>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<27>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<26>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<25>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<24>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<23>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<22>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<21>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<20>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<19>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<18>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<17>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<16>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<15>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<14>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<13>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<11>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<12>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<10>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<9>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<8>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<7>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<6>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<5>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<4>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<3>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<2>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<1>::least(u) == u ); u >>= 1;
BOOST_TEST( uint_t<0>::least(u) == u );
u = 0xFFFFFFFF;
BOOST_TEST( uint_t<32>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<31>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<30>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<29>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<28>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<27>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<26>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<25>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<24>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<23>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<22>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<21>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<20>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<19>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<18>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<17>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<16>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<15>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<14>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<13>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<12>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<11>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<10>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<9>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<8>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<7>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<6>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<5>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<4>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<3>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<2>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<1>::fast(u) == u ); u >>= 1;
BOOST_TEST( uint_t<0>::fast(u) == u );
return 0;
}

View File

@ -1,89 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>integer_traits: Compile-Time Limits for Integral Types</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Compile-Time Integral
Type Limits</h1>
<p>
The C++ Standard Library &lt;limits&gt; header supplies a class template
numeric_limits&lt;&gt; with specializations for each fundamental
type.</p>
<p>
For integer types, the interesting members of std::numeric_limits&lt;&gt; are:
<pre> static const bool is_specialized; // will be true for integers
static T min() throw();
static T max() throw();
static const int digits; // for integers, # value bits
static const int digits10;
static const bool is_signed;
static const bool is_integer; // will be true for integers</pre>
For many uses, these are sufficient. But min() and max() are problematical because they are not constant expressions
(std::5.19), yet some usages require constant expressions.
<p>
The template class <code>integer_traits</code> addresses this
problem.
<h2>Header <code><a href="../../boost/integer_traits.hpp">integer_traits.hpp</a></code> Synopsis</h2>
<pre>namespace boost {
template&lt;class T&gt;
class integer_traits : public std::numeric_limits&lt;T&gt;
{
static const bool is_integral = false;
};
// specializations for all integral types
}</pre>
<h2>Description</h2>
Template class <code>integer_traits</code> is derived from
<code>std::numeric_limits</code>. In general, it adds the single
<code>bool</code> member <code>is_integral</code> with the
compile-time constant value <code>false</code>. However, for all
integral types <code>T</code> (std::3.9.1/7 [basic.fundamental]),
there are specializations provided with the following compile-time
constants defined:
<p>
<table border=1>
<tr><th>member</th><th>type</th><th>value</th></tr>
<tr><td><code>is_integral</code></td><td>bool</td><td><code>true</code></td></tr>
<tr><td><code>const_min</code></td><td><code>T</code></td><td>equivalent
to <code>std::numeric_limits&lt;T&gt;::min()</code></td></tr>
<tr><td><code>const_max</code></td><td><code>T</code></td><td>equivalent
to <code>std::numeric_limits&lt;T&gt;::max()</code></td></tr>
</table>
<p>
<em>Note:</em> A flag <code>is_integral</code> is provided, because a
user-defined integer class should specialize
<code>std::numeric_limits&lt;&gt;::is_integer = true</code>,
nonetheless compile-time constants <code>const_min</code> and
<code>const_max</code> cannot be provided for that user-defined class.
<h2>
Test Program</h2>
<p>
The program <code><a href="integer_traits_test.cpp">integer_traits_test.cpp</a></code>
exercises the <code>integer_traits</code> class.
<h2>Acknowledgements</h2>
Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers discussed the integer
traits idea on the boost mailing list in August 1999.
<hr>
<a href="../../people/jens_maurer.htm">
Jens Maurer</a>, 2000-02-20

View File

@ -1,84 +0,0 @@
/* boost integer_traits.hpp tests
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without free provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
* Jens Maurer makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* $Id$
*
* Revision history
* 2000-02-22 Small improvements by Beman Dawes
* 2000-06-27 Rework for better MSVC and BCC co-operation
*/
#include <iostream>
#include <cassert>
#include <boost/integer_traits.hpp>
// use int64_t instead of long long for better portability
#include <boost/cstdint.hpp>
#ifdef NDEBUG
#error This test relies on assert() and thus makes no sense with NDEBUG defined
#endif
/*
* General portability note:
* MSVC mis-compiles explicit function template instantiations.
* For example, f<A>() and f<B>() are both compiled to call f<A>().
* BCC is unable to implicitly convert a "const char *" to a std::string
* when using explicit function template instantiations.
*
* Therefore, avoid explicit function template instantiations.
*/
template<class T>
void runtest(const char * type, T)
{
typedef boost::integer_traits<T> traits;
std::cout << "Checking " << type
<< "; min is " << traits::min()
<< ", max is " << traits::max()
<< std::endl;
assert(traits::is_specialized);
assert(traits::is_integer);
assert(traits::is_integral);
assert(traits::const_min == traits::min());
assert(traits::const_max == traits::max());
}
int main()
{
runtest("bool", bool());
runtest("char", char());
typedef signed char signed_char;
runtest("signed char", signed_char());
typedef unsigned char unsigned_char;
runtest("unsigned char", unsigned_char());
runtest("short", short());
typedef unsigned short unsigned_short;
runtest("unsigned short", unsigned_short());
runtest("int", int());
typedef unsigned int unsigned_int;
runtest("unsigned int", unsigned_int());
runtest("long", long());
typedef unsigned long unsigned_long;
runtest("unsigned long", unsigned_long());
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__) && !defined(__BEOS__)
//
// MS/Borland compilers can't support 64-bit member constants
// BeOS doesn't have specialisations for long long in SGI's <limits> header.
runtest("int64_t (possibly long long)", boost::int64_t());
runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
#endif
// Some compilers don't pay attention to std:3.6.1/5 and issue a
// warning here if "return 0;" is omitted.
return 0;
}