Compare commits

..

28 Commits

Author SHA1 Message Date
b3b5b039f7 Changed BOOST_SYSTEM_HAS_STDINT_H to BOOST_HAS_STDINT_H
[SVN r10888]
2001-08-18 10:25:02 +00:00
0462a811f6 This commit was manufactured by cvs2svn to create branch 'split-config'.
[SVN r10742]
2001-08-04 14:31:38 +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
b519841b7f Change all eGroups references to YahooGroups
[SVN r9979]
2001-04-25 00:24:50 +00:00
d1781f09d2 allow for ULONGLONG_MAX as well
[SVN r9795]
2001-04-16 13:32:54 +00:00
c1c099c845 check for ULONGLONG_MAX as well
[SVN r9793]
2001-04-16 12:53:03 +00:00
f4c38bdf51 Added boost-wide <limits> woraround
[SVN r9688]
2001-04-01 11:59:18 +00:00
53005cadc8 added <limits> workaround
[SVN r9687]
2001-03-31 12:05:02 +00:00
ea4963031a Add comment: int_fast_t works for unsigned too.
[SVN r9545]
2001-03-12 14:01:34 +00:00
873879d5ac Use test_tools.hpp for error detection
[SVN r9540]
2001-03-11 13:31:00 +00:00
d39c7cd327 Correct spelling in Jens' licenses
[SVN r9372]
2001-03-01 18:54:36 +00:00
37eb749c49 Fix for BeOS <limits>
[SVN r9356]
2001-02-27 12:52:08 +00:00
8084359fda removed backslashes in macros
[SVN r9097]
2001-02-11 01:21:56 +00:00
9 changed files with 251 additions and 57 deletions

View File

@ -69,7 +69,7 @@ representing any value of any signed integer type.</p>
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 -->18 Nov 2000<!--webbot bot="Timestamp" endspan i-checksum="15249" -->
<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>

View File

@ -9,6 +9,7 @@
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 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)
// 23 Sep 00 Added INTXX_C macro support (John Maddock).
@ -23,9 +24,19 @@
#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 nice <stdint.h> in a non-standard location
# include <sys/_inttypes.h>
# ifdef __STDC_32_MODE__
// this is triggered with GCC, because it defines __cplusplus < 199707L
# define BOOST_NO_INT64_T
# endif
# else
# include <stdint.h>
# endif
namespace boost
{
@ -68,7 +79,7 @@ namespace boost
} // namespace boost
#else // BOOST_SYSTEM_HAS_STDINT_H
#else // BOOST_HAS_STDINT_H
# include <limits.h> // implementation artifact; not part of interface
@ -133,9 +144,10 @@ namespace boost
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX))
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U)
# if !defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
(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)
// 2**64 - 1
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
@ -183,7 +195,7 @@ namespace boost
} // namespace boost
#endif // BOOST_SYSTEM_HAS_STDINT_H
#endif // BOOST_HAS_STDINT_H
#endif // BOOST_CSTDINT_HPP
@ -253,9 +265,11 @@ Added 23rd September (John Maddock).
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX))
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
# if defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX)
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
# if (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
(defined(ULONG_LONG_MAX) && (defined(__hpux) || ULONG_LONG_MAX == 18446744073709551615U)) || \
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
# define INT64_C(value) value##LL
# define UINT64_C(value) value##uLL
# else
@ -299,3 +313,4 @@ Added 23rd September (John Maddock).
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.

View File

@ -9,13 +9,14 @@
// See http://www.boost.org for most recent version including documentation.
// Revision History
// 30 Jul 00 Add typename syntax fix (Jens Maurer)
// 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
#ifndef BOOST_INTEGER_HPP
#define BOOST_INTEGER_HPP
#include <limits>
#include <boost/limits.hpp>
namespace boost
{
@ -23,6 +24,7 @@ namespace boost
// Helper templates ------------------------------------------------------//
// fast integers from least integers
// int_fast_t<> works correctly for unsigned too, in spite of the name.
template< typename LeastInt >
struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
@ -70,6 +72,7 @@ namespace boost
(Bits <= std::numeric_limits<unsigned char>::digits)
>::least least;
typedef typename int_fast_t<least>::fast fast;
// 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

View File

@ -2,7 +2,7 @@
*
* 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
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
@ -18,11 +18,14 @@
#ifndef BOOST_INTEGER_TRAITS_HPP
#define BOOST_INTEGER_TRAITS_HPP
#include <limits>
#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>
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
#include <wchar.h>
#endif
namespace boost {
@ -30,11 +33,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 +41,20 @@ 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
// The definition is required even for integral static constants
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 +81,25 @@ 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(__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)
// SGI MIPSpro with native library doesn't have them, either
public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
#elif defined(__hpux) && defined(__GNUC__) && !defined(__SGI_STL_PORT)
// GCC 2.95.2 doesn't have them on HP-UX, either
// (also, std::numeric_limits<wchar_t> appears to return the wrong values)
public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
#else
public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
#endif
{ };
#endif // BOOST_NO_INTRINSIC_WCHAR_T
template<>
class integer_traits<short>
@ -140,8 +159,20 @@ 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) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
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>
{ };
#endif
} // namespace boost
#endif /* BOOST_INTEGER_TRAITS_HPP */

View File

@ -14,11 +14,11 @@
// 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
// <stdint.h> or not. For example, in case BOOST_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
// BOOST_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.
//
@ -40,7 +40,7 @@
#include <boost/config.hpp>
#ifdef BOOST_SYSTEM_HAS_STDINT_H
#ifdef BOOST_HAS_STDINT_H
#include <stdint.h>
#else
@ -150,7 +150,7 @@
typedef uint32_t uintmax_t;
# endif
#endif // BOOST_SYSTEM_HAS_STDINT_H not defined
#endif // BOOST_HAS_STDINT_H not defined
#endif // BOOST_STDINT_H
/****************************************************

View File

@ -90,7 +90,7 @@ instead.
<hr>
<p>Revised: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %b %Y" startspan -->18 Nov 2000<!--webbot bot="Timestamp" endspan i-checksum="15249" -->
<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>

View File

@ -34,6 +34,7 @@ appropriate to use the types supplied in <code><a href="../../boost/cstdint.hpp"
<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
@ -51,6 +52,7 @@ appropriate to use the types supplied in <code><a href="../../boost/cstdint.hpp"
{
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>

View File

@ -9,14 +9,15 @@
// 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
// This program is misnamed in that it is really a demonstration rather than
// a test. It doesn't detect failure, so isn't worthy of the name "test".
#include <iostream>
#include <boost/integer.hpp>
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
namespace
{
void test( long ) { std::cout << "long\n"; }
@ -35,10 +36,12 @@ namespace boost
template<> struct int_fast_t<short> { typedef long fast; };
}
int main()
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() );
@ -170,7 +173,145 @@ int main()
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() );
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

@ -2,7 +2,7 @@
*
* 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
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
@ -18,15 +18,12 @@
*/
#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
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
/*
* General portability note:
@ -46,14 +43,14 @@ void runtest(const char * type, T)
<< "; 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());
BOOST_TEST(traits::is_specialized);
BOOST_TEST(traits::is_integer);
BOOST_TEST(traits::is_integral);
BOOST_TEST(traits::const_min == traits::min());
BOOST_TEST(traits::const_max == traits::max());
}
int main()
int test_main(int, char*[])
{
runtest("bool", bool());
runtest("char", char());
@ -61,6 +58,7 @@ int main()
runtest("signed char", signed_char());
typedef unsigned char unsigned_char;
runtest("unsigned char", unsigned_char());
runtest("wchar_t", wchar_t());
runtest("short", short());
typedef unsigned short unsigned_short;
runtest("unsigned short", unsigned_short());
@ -70,13 +68,17 @@ int main()
runtest("long", long());
typedef unsigned long unsigned_long;
runtest("unsigned long", unsigned_long());
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
#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());
#else
std::cout << "Skipped int64_t and uint64_t" << std::endl;
#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;
}