diff --git a/doc/html/boost_integer/history.html b/doc/html/boost_integer/history.html
index fb7fc8a..6d4b878 100644
--- a/doc/html/boost_integer/history.html
+++ b/doc/html/boost_integer/history.html
@@ -26,7 +26,7 @@
History
-
diff --git a/doc/html/boost_integer/integer.html b/doc/html/boost_integer/integer.html
index 8772326..50d58d9 100644
--- a/doc/html/boost_integer/integer.html
+++ b/doc/html/boost_integer/integer.html
@@ -61,6 +61,8 @@
template<int Bits>
struct int_t
{
+
+ typedef implementation-defined-type exact;
typedef implementation-defined-type least;
typedef int_fast_t<least>::fast fast;
};
@@ -69,6 +71,8 @@
template<int Bits>
struct uint_t
{
+
+ typedef implementation-defined-type exact;
typedef implementation-defined-type least;
typedef int_fast_t<least>::fast fast;
};
@@ -136,7 +140,7 @@
fast
. The following table describes each template's criteria.
-
Table 1. Criteria for the Sized Type Class Templates
+
Table 1. Criteria for the Sized Type Class Templates
@@ -166,7 +170,9 @@
The smallest built-in signed integral type with at least N
bits, including the sign bit. The parameter should be a positive number.
A compile-time error results if the parameter is larger than the number
- of bits in the largest integer type.
+ of bits in the largest integer type. Note that the member exact
+ is defined only if there is a type
+ with exactly N bits.
@@ -181,7 +187,9 @@
The smallest built-in unsigned integral type with at least N
bits. The parameter should be a positive number. A compile-time error
results if the parameter is larger than the number of bits in the largest
- integer type.
+ integer type. Note that the member exact is defined
+ only if there is a type with exactly
+ N bits.
diff --git a/doc/html/boost_integer/mask.html b/doc/html/boost_integer/mask.html
index e8ca8e2..9aee7d0 100644
--- a/doc/html/boost_integer/mask.html
+++ b/doc/html/boost_integer/mask.html
@@ -105,7 +105,7 @@
of high_bit_mask_t
.
-
Table 2. Members of the `boost::high_bit_mask_t` Class Template
+
Table 2. Members of the `boost::high_bit_mask_t` Class Template
@@ -205,7 +205,7 @@
the members of an instantiation of low_bits_mask_t
.
-
Table 3. Members of the [^boost::low_bits_mask_t] Class Template
+
Table 3. Members of the [^boost::low_bits_mask_t] Class Template
diff --git a/doc/html/index.html b/doc/html/index.html
index 69f0579..dab3f7c 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -40,7 +40,7 @@
Copyright © 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock
-Last revised: November 25, 2009 at 12:02:32 GMT |
+Last revised: November 26, 2009 at 11:06:43 GMT |
|
diff --git a/doc/integer.qbk b/doc/integer.qbk
index 403b010..36f9a1b 100644
--- a/doc/integer.qbk
+++ b/doc/integer.qbk
@@ -282,6 +282,8 @@ This facility is particularly useful for solving generic programming problems.
template
struct int_t
{
+ /* Member exact may or may not be defined depending upon Bits */
+ typedef ``['implementation-defined-type]`` exact;
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t::fast fast;
};
@@ -290,6 +292,8 @@ This facility is particularly useful for solving generic programming problems.
template
struct uint_t
{
+ /* Member exact may or may not be defined depending upon Bits */
+ typedef ``['implementation-defined-type]`` exact;
typedef ``['implementation-defined-type]`` least;
typedef int_fast_t::fast fast;
};
@@ -351,13 +355,16 @@ The following table describes each template's criteria.
[[^boost::int_t]]
[The smallest built-in signed integral type with at least /N/ bits, including the sign bit.
The parameter should be a positive number. A compile-time error results if the parameter is
- larger than the number of bits in the largest integer type.]
+ larger than the number of bits in the largest integer type. Note that the member /exact/ is defined
+ [*only] if there is a type with exactly N bits.]
]
[
[[^boost::uint_t]]
[The smallest built-in unsigned integral type with at least /N/ bits.
The parameter should be a positive number. A compile-time error results if the
- parameter is larger than the number of bits in the largest integer type.]
+ parameter is larger than the number of bits in the largest integer type.
+ Note that the member /exact/ is defined
+ [*only] if there is a type with exactly N bits.]
]
[
[[^boost::int_max_value_t]]
diff --git a/include/boost/integer.hpp b/include/boost/integer.hpp
index 86cc3a5..7125ca6 100644
--- a/include/boost/integer.hpp
+++ b/include/boost/integer.hpp
@@ -21,6 +21,18 @@
#include // for ::std::numeric_limits
#include // for boost::int64_t and BOOST_NO_INTEGRAL_INT64_T
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
namespace boost
{
@@ -54,13 +66,42 @@ namespace boost
template<> struct int_least_helper<9> { typedef unsigned short least; };
template<> struct int_least_helper<10> { typedef unsigned char least; };
+ template
+ struct exact_signed_base_helper{};
+ template
+ struct exact_unsigned_base_helper{};
+
+ template <> struct exact_signed_base_helper { typedef signed char exact; };
+ template <> struct exact_unsigned_base_helper { typedef unsigned char exact; };
+#if USHRT_MAX != UCHAR_MAX
+ template <> struct exact_signed_base_helper { typedef short exact; };
+ template <> struct exact_unsigned_base_helper { typedef unsigned short exact; };
+#endif
+#if UINT_MAX != USHRT_MAX
+ template <> struct exact_signed_base_helper { typedef int exact; };
+ template <> struct exact_unsigned_base_helper { typedef unsigned int exact; };
+#endif
+#if ULONG_MAX != UINT_MAX
+ template <> struct exact_signed_base_helper { typedef long exact; };
+ template <> struct exact_unsigned_base_helper { typedef unsigned long exact; };
+#endif
+#if defined(BOOST_HAS_LONG_LONG) &&\
+ ((defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX)) ||\
+ (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX)) ||\
+ (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX)) ||\
+ (defined(_ULLONG_MAX) && (_ULLONG_MAX != ULONG_MAX)))
+ template <> struct exact_signed_base_helper { typedef long long exact; };
+ template <> struct exact_unsigned_base_helper { typedef unsigned long long exact; };
+#endif
+
+
} // namespace detail
// integer templates specifying number of bits ---------------------------//
// signed
template< int Bits > // bits (including sign) required
- struct int_t
+ struct int_t : public detail::exact_signed_base_helper
{
typedef typename detail::int_least_helper
<
@@ -79,7 +120,7 @@ namespace boost
// unsigned
template< int Bits > // bits required
- struct uint_t
+ struct uint_t : public detail::exact_unsigned_base_helper
{
typedef typename detail::int_least_helper
<
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 03adbd9..9104efc 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -5,11 +5,11 @@
import testing ;
test-suite integer
- : [ run cstdint_test.cpp ]
- [ run integer_test.cpp
- /boost/test//minimal ]
+ : [ run cstdint_test.cpp /boost/test//minimal ]
[ run integer_traits_test.cpp
/boost/test//boost_test_exec_monitor ]
+ [ run integer_test.cpp
+ /boost/test//minimal ]
[ run integer_mask_test.cpp
/boost/test//minimal ]
[ run static_log2_test.cpp
diff --git a/test/cstdint_test.cpp b/test/cstdint_test.cpp
index 88422de..6d26b91 100644
--- a/test/cstdint_test.cpp
+++ b/test/cstdint_test.cpp
@@ -13,17 +13,10 @@
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
// 28 Jun 00 Initial version
#define __STDC_CONSTANT_MACROS
-#include
#include
#include
+#include
-#ifdef NDEBUG
-int main()
-{
- std::cout << "This test makes no sense with NDEBUG defined.\n";
- return 0;
-}
-#else
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
@@ -62,24 +55,24 @@ struct integral_constant_checker
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 );
+ BOOST_CHECK( int8 == -127 );
+ BOOST_CHECK( int_least8 == -127 );
+ BOOST_CHECK( int_fast8 == -127 );
+ BOOST_CHECK( uint8 == 255u );
+ BOOST_CHECK( uint_least8 == 255u );
+ BOOST_CHECK( uint_fast8 == 255u );
+ BOOST_CHECK( int16 == -32767 );
+ BOOST_CHECK( int_least16 == -32767 );
+ BOOST_CHECK( int_fast16 == -32767 );
+ BOOST_CHECK( uint16 == 65535u );
+ BOOST_CHECK( uint_least16 == 65535u );
+ BOOST_CHECK( uint_fast16 == 65535u );
+ BOOST_CHECK( int32 == -2147483647 );
+ BOOST_CHECK( int_least32 == -2147483647 );
+ BOOST_CHECK( int_fast32 == -2147483647 );
+ BOOST_CHECK( uint32 == 4294967295u );
+ BOOST_CHECK( uint_least32 == 4294967295u );
+ BOOST_CHECK( uint_fast32 == 4294967295u );
}
#endif // BOOST_NO_INCLASS_MEMBER_INITIALIZATION
@@ -108,10 +101,10 @@ void integral_constant_type_check(T1, T2)
// if we have a native stdint.h
// then the INTXX_C macros may define
// a type that's wider than required:
- assert(sizeof(T1) <= sizeof(T2));
+ BOOST_CHECK(sizeof(T1) <= sizeof(T2));
#else
- assert(sizeof(T1) == sizeof(T2));
- assert(t1 == t2);
+ BOOST_CHECK(sizeof(T1) == sizeof(T2));
+ BOOST_CHECK(t1 == t2);
#endif
#if defined(BOOST_HAS_STDINT_H)
// native headers are permitted to promote small
@@ -119,22 +112,22 @@ void integral_constant_type_check(T1, T2)
if(sizeof(T1) >= sizeof(int))
{
if(t1 > 0)
- assert(t2 > 0);
+ BOOST_CHECK(t2 > 0);
else
- assert(!(t2 > 0));
+ BOOST_CHECK(!(t2 > 0));
}
else if(t1 < 0)
- assert(!(t2 > 0));
+ BOOST_CHECK(!(t2 > 0));
#else
if(t1 > 0)
- assert(t2 > 0);
+ BOOST_CHECK(t2 > 0);
else
- assert(!(t2 > 0));
+ BOOST_CHECK(!(t2 > 0));
#endif
}
-int main()
+int test_main(int, char*[])
{
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
integral_constant_checker::check();
@@ -193,41 +186,40 @@ int main()
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 );
+ BOOST_CHECK( int8 == -127 );
+ BOOST_CHECK( int_least8 == -127 );
+ BOOST_CHECK( int_fast8 == -127 );
+ BOOST_CHECK( uint8 == 255u );
+ BOOST_CHECK( uint_least8 == 255u );
+ BOOST_CHECK( uint_fast8 == 255u );
+ BOOST_CHECK( int16 == -32767 );
+ BOOST_CHECK( int_least16 == -32767 );
+ BOOST_CHECK( int_fast16 == -32767 );
+ BOOST_CHECK( uint16 == 65535u );
+ BOOST_CHECK( uint_least16 == 65535u );
+ BOOST_CHECK( uint_fast16 == 65535u );
+ BOOST_CHECK( int32 == -2147483647 );
+ BOOST_CHECK( int_least32 == -2147483647 );
+ BOOST_CHECK( int_fast32 == -2147483647 );
+ BOOST_CHECK( uint32 == 4294967295u );
+ BOOST_CHECK( uint_least32 == 4294967295u );
+ BOOST_CHECK( 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) );
+ BOOST_CHECK( int64 == INT64_C(-9223372036854775807) );
+ BOOST_CHECK( int_least64 == INT64_C(-9223372036854775807) );
+ BOOST_CHECK( int_fast64 == INT64_C(-9223372036854775807) );
+ BOOST_CHECK( uint64 == UINT64_C(18446744073709551615) );
+ BOOST_CHECK( uint_least64 == UINT64_C(18446744073709551615) );
+ BOOST_CHECK( uint_fast64 == UINT64_C(18446744073709551615) );
+ BOOST_CHECK( intmax == INT64_C(-9223372036854775807) );
+ BOOST_CHECK( uintmax == UINT64_C(18446744073709551615) );
#else
- assert( intmax == -2147483647 );
- assert( uintmax == 4294967295u );
+ BOOST_CHECK( intmax == -2147483647 );
+ BOOST_CHECK( uintmax == 4294967295u );
#endif
std::cout << "OK\n";
return 0;
}
-#endif
diff --git a/test/integer_test.cpp b/test/integer_test.cpp
index c6c3e8a..e70ac86 100644
--- a/test/integer_test.cpp
+++ b/test/integer_test.cpp
@@ -1,6 +1,9 @@
// boost integer.hpp test program ------------------------------------------//
-// Copyright Beman Dawes 1999. Distributed under the Boost
+// Copyright Beman Dawes 1999.
+// Copyright Daryle Walker 2001.
+// Copyright John Maddock 2009.
+// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -13,10 +16,8 @@
// 31 Aug 99 Initial version
#include // for main, BOOST_CHECK
-
-#include // for BOOST_NO_USING_TEMPLATE
-#include // for boost::exit_success
#include // for boost::int_t, boost::uint_t
+#include
#include // for ULONG_MAX, LONG_MAX, LONG_MIN
#include // for std::cout (std::endl indirectly)
@@ -25,271 +26,222 @@
#ifdef BOOST_MSVC
#pragma warning(disable:4127) // conditional expression is constant
#endif
-
-
-// Control if the names of the types for each version
-// of the integer templates will be printed.
-#ifndef CONTROL_SHOW_TYPES
-#define CONTROL_SHOW_TYPES 0
+//
+// Keep track of error count, so we can print out detailed
+// info only if we need it:
+//
+unsigned last_error_count = 0;
+//
+// Helpers to print out the name of a type,
+// we use these as typeid(X).name() doesn't always
+// return a human readable string:
+//
+template const char* get_name_of_type(T){ return typeid(T).name(); }
+const char* get_name_of_type(signed char){ return "signed char"; }
+const char* get_name_of_type(unsigned char){ return "unsigned char"; }
+const char* get_name_of_type(short){ return "short"; }
+const char* get_name_of_type(unsigned short){ return "unsigned short"; }
+const char* get_name_of_type(int){ return "int"; }
+const char* get_name_of_type(unsigned int){ return "unsigned int"; }
+const char* get_name_of_type(long){ return "long"; }
+const char* get_name_of_type(unsigned long){ return "unsigned long"; }
+#ifdef BOOST_HAS_LONG_LONG
+const char* get_name_of_type(long long){ return "long long"; }
+const char* get_name_of_type(unsigned long long){ return "unsigned long long"; }
#endif
-
-// If specializations have not already been done, then we can confirm
-// the effects of the "fast" types by making a specialization.
-namespace boost
+template
+void do_test_exact(boost::mpl::true_ const&)
{
- template < >
- struct int_fast_t< short >
- {
- typedef long fast;
- };
+ // Test the ::exact member:
+ typedef typename boost::int_t::exact int_exact;
+ typedef typename boost::uint_t::exact uint_exact;
+ typedef typename boost::int_t::least least_int;
+ typedef typename boost::uint_t::least least_uint;
+
+ BOOST_CHECK((boost::is_same::value));
+ BOOST_CHECK((boost::is_same::value));
+}
+template
+void do_test_exact(boost::mpl::false_ const&)
+{
+ // Nothing to do, type does not have an ::extact member.
}
-
-// Show the types of an integer template version
-#if CONTROL_SHOW_TYPES
-#define SHOW_TYPE(Template, Number, Type) ::std::cout << "Type \"" \
- #Template "<" #Number ">::" #Type "\" is \"" << typeid(Template < \
- Number > :: Type).name() << ".\"\n"
-#else
-#define SHOW_TYPE(Template, Number, Type)
+template
+void do_test_bits()
+{
+ //
+ // Recurse to next smallest number of bits:
+ //
+ do_test_bits();
+ //
+ // Test exact types if we have them:
+ //
+ do_test_exact(
+ boost::mpl::bool_<
+ (sizeof(unsigned char) * CHAR_BIT == Bits)
+ || (sizeof(unsigned short) * CHAR_BIT == Bits)
+ || (sizeof(unsigned int) * CHAR_BIT == Bits)
+ || (sizeof(unsigned long) * CHAR_BIT == Bits)
+#ifdef BOOST_HAS_LONG_LONG
+ || (sizeof(unsigned long long) * CHAR_BIT == Bits)
#endif
+ >());
+ //
+ // We need to check all aspects of the members of int_t and uint_t:
+ //
+ typedef typename boost::int_t::least least_int;
+ typedef typename boost::int_t::least fast_int;
+ typedef typename boost::uint_t::least least_uint;
+ typedef typename boost::uint_t::fast fast_uint;
-#define SHOW_TYPES(Template, Type) SHOW_TYPE(Template, 32, Type); \
- SHOW_TYPE(Template, 31, Type); SHOW_TYPE(Template, 30, Type); \
- SHOW_TYPE(Template, 29, Type); SHOW_TYPE(Template, 28, Type); \
- SHOW_TYPE(Template, 27, Type); SHOW_TYPE(Template, 26, Type); \
- SHOW_TYPE(Template, 25, Type); SHOW_TYPE(Template, 24, Type); \
- SHOW_TYPE(Template, 23, Type); SHOW_TYPE(Template, 22, Type); \
- SHOW_TYPE(Template, 21, Type); SHOW_TYPE(Template, 20, Type); \
- SHOW_TYPE(Template, 19, Type); SHOW_TYPE(Template, 18, Type); \
- SHOW_TYPE(Template, 17, Type); SHOW_TYPE(Template, 16, Type); \
- SHOW_TYPE(Template, 15, Type); SHOW_TYPE(Template, 14, Type); \
- SHOW_TYPE(Template, 13, Type); SHOW_TYPE(Template, 12, Type); \
- SHOW_TYPE(Template, 11, Type); SHOW_TYPE(Template, 10, Type); \
- SHOW_TYPE(Template, 9, Type); SHOW_TYPE(Template, 8, Type); \
- SHOW_TYPE(Template, 7, Type); SHOW_TYPE(Template, 6, Type); \
- SHOW_TYPE(Template, 5, Type); SHOW_TYPE(Template, 4, Type); \
- SHOW_TYPE(Template, 3, Type); SHOW_TYPE(Template, 2, Type); \
- SHOW_TYPE(Template, 1, Type); SHOW_TYPE(Template, 0, Type)
+ if(std::numeric_limits::is_specialized)
+ {
+ BOOST_CHECK(std::numeric_limits::digits + 1 >= Bits);
+ }
+ if(std::numeric_limits::is_specialized)
+ {
+ BOOST_CHECK(std::numeric_limits::digits >= Bits);
+ }
+ BOOST_CHECK(sizeof(least_int) * CHAR_BIT >= Bits);
+ BOOST_CHECK(sizeof(least_uint) * CHAR_BIT >= Bits);
+ BOOST_CHECK(sizeof(fast_int) >= sizeof(least_int));
+ BOOST_CHECK(sizeof(fast_uint) >= sizeof(least_uint));
+ //
+ // There should be no type smaller than least_* that also has enough bits:
+ //
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ }
+ }
+ }
+ }
+ // And again, but unsigned:
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ if(!boost::is_same::value)
+ {
+ BOOST_CHECK(std::numeric_limits::digits < Bits);
+ }
+ }
+ }
+ }
-#define SHOW_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, (1UL << Number), Type)
-
-#define SHOW_SHIFTED_TYPES(Template, Type) SHOW_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_SHIFTED_TYPE(Template, 29, Type); SHOW_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_SHIFTED_TYPE(Template, 27, Type); SHOW_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_SHIFTED_TYPE(Template, 25, Type); SHOW_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_SHIFTED_TYPE(Template, 23, Type); SHOW_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_SHIFTED_TYPE(Template, 21, Type); SHOW_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_SHIFTED_TYPE(Template, 19, Type); SHOW_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_SHIFTED_TYPE(Template, 17, Type); SHOW_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_SHIFTED_TYPE(Template, 15, Type); SHOW_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_SHIFTED_TYPE(Template, 13, Type); SHOW_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_SHIFTED_TYPE(Template, 11, Type); SHOW_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_SHIFTED_TYPE(Template, 9, Type); SHOW_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_SHIFTED_TYPE(Template, 7, Type); SHOW_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_SHIFTED_TYPE(Template, 5, Type); SHOW_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_SHIFTED_TYPE(Template, 3, Type); SHOW_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_SHIFTED_TYPE(Template, 1, Type); SHOW_SHIFTED_TYPE(Template, 0, Type)
-
-#define SHOW_POS_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, +(1L << Number), Type)
-
-#define SHOW_POS_SHIFTED_TYPES(Template, Type) SHOW_POS_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 29, Type); SHOW_POS_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 27, Type); SHOW_POS_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 25, Type); SHOW_POS_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 23, Type); SHOW_POS_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 21, Type); SHOW_POS_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 19, Type); SHOW_POS_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 17, Type); SHOW_POS_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 15, Type); SHOW_POS_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 13, Type); SHOW_POS_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 11, Type); SHOW_POS_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 9, Type); SHOW_POS_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 7, Type); SHOW_POS_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 5, Type); SHOW_POS_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 3, Type); SHOW_POS_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_POS_SHIFTED_TYPE(Template, 1, Type); SHOW_POS_SHIFTED_TYPE(Template, 0, Type)
-
-#define SHOW_NEG_SHIFTED_TYPE(Template, Number, Type) SHOW_TYPE(Template, -(1L << Number), Type)
-
-#define SHOW_NEG_SHIFTED_TYPES(Template, Type) SHOW_NEG_SHIFTED_TYPE(Template, 30, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 29, Type); SHOW_NEG_SHIFTED_TYPE(Template, 28, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 27, Type); SHOW_NEG_SHIFTED_TYPE(Template, 26, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 25, Type); SHOW_NEG_SHIFTED_TYPE(Template, 24, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 23, Type); SHOW_NEG_SHIFTED_TYPE(Template, 22, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 21, Type); SHOW_NEG_SHIFTED_TYPE(Template, 20, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 19, Type); SHOW_NEG_SHIFTED_TYPE(Template, 18, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 17, Type); SHOW_NEG_SHIFTED_TYPE(Template, 16, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 15, Type); SHOW_NEG_SHIFTED_TYPE(Template, 14, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 13, Type); SHOW_NEG_SHIFTED_TYPE(Template, 12, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 11, Type); SHOW_NEG_SHIFTED_TYPE(Template, 10, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 9, Type); SHOW_NEG_SHIFTED_TYPE(Template, 8, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 7, Type); SHOW_NEG_SHIFTED_TYPE(Template, 6, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 5, Type); SHOW_NEG_SHIFTED_TYPE(Template, 4, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 3, Type); SHOW_NEG_SHIFTED_TYPE(Template, 2, Type); \
- SHOW_NEG_SHIFTED_TYPE(Template, 1, Type); SHOW_NEG_SHIFTED_TYPE(Template, 0, Type)
-
-
-// Test if a constant can fit within a certain type
-#define PRIVATE_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < Number > :: Type ( Value ) == Value )
-
-#if (ULONG_MAX > 0xFFFFFFFFL) || !defined(BOOST_NO_INTEGRAL_INT64_T)
-#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_FIT_TEST(Template, 64, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 63, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 62, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 61, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 60, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 59, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 58, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 57, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 56, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 55, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 54, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 53, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 52, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 51, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 50, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 49, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 48, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 47, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 46, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 45, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 44, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 43, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 42, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 41, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 40, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 39, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 38, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 37, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 36, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 35, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 34, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 33, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 31, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 30, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 29, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 28, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 27, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 26, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 25, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 24, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 23, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 22, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 21, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 20, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 19, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 18, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 17, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 16, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 15, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 14, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 13, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 12, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 11, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 10, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 9, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 8, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 7, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 6, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 5, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 4, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 3, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 2, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 1, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 0, Type, v); } while ( false )
-#else
-#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 31, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 30, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 29, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 28, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 27, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 26, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 25, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 24, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 23, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 22, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 21, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 20, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 19, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 18, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 17, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 16, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 15, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 14, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 13, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 12, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 11, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 10, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 9, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 8, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 7, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 6, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 5, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 4, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 3, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 2, Type, v); v >>= 1; \
- PRIVATE_FIT_TEST(Template, 1, Type, v); v >>= 1; PRIVATE_FIT_TEST(Template, 0, Type, v); } while ( false )
-#endif
-
-#define PRIVATE_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (ULONG_MAX >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_SHIFTED_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
-
-#define PRIVATE_POS_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (LONG_MAX >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_POS_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_POS_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_POS_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
-
-#define PRIVATE_NEG_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < (LONG_MIN >> Number) > :: Type ( Value ) == Value )
-
-#define PRIVATE_NEG_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 0, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 1, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 2, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 3, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 4, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 5, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 6, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 7, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 8, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 9, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 10, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 11, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 12, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 13, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 14, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 15, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 16, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 17, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 18, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 19, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 20, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 21, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 22, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 23, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 24, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 25, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 26, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 27, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 28, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 29, Type, v); v >>= 1; \
- PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 30, Type, v); v >>= 1; PRIVATE_NEG_SHIFTED_FIT_TEST(Template, 31, Type, v); } while ( false )
+ if(boost::minimal_test::errors_counter() != last_error_count)
+ {
+ last_error_count = boost::minimal_test::errors_counter();
+ std::cout << "Errors occured while testing with bit count = " << Bits << std::endl;
+ std::cout << "Type int_t<" << Bits << ">::least was " << get_name_of_type(least_int(0)) << std::endl;
+ std::cout << "Type int_t<" << Bits << ">::fast was " << get_name_of_type(fast_int(0)) << std::endl;
+ std::cout << "Type uint_t<" << Bits << ">::least was " << get_name_of_type(least_uint(0)) << std::endl;
+ std::cout << "Type uint_t<" << Bits << ">::fast was " << get_name_of_type(fast_uint(0)) << std::endl;
+ }
+}
+template <>
+void do_test_bits<-1>()
+{
+ // Nothing to do here!!
+}
+template
+void test_min_max_type(Expected val)
+{
+ typedef typename Traits::least least_type;
+ typedef typename Traits::fast fast_type;
+ BOOST_CHECK((boost::is_same::value));
+ BOOST_CHECK(sizeof(fast_type) >= sizeof(least_type));
+ BOOST_CHECK((std::numeric_limits::min)() <= val);
+ BOOST_CHECK((std::numeric_limits::max)() >= val);
+}
// Test program
-int
-test_main
-(
- int,
- char*[]
-)
+int test_main(int, char*[])
{
-#ifndef BOOST_NO_USING_TEMPLATE
- using boost::int_t;
- using boost::uint_t;
- using boost::int_max_value_t;
- using boost::int_min_value_t;
- using boost::uint_value_t;
-#else
- using namespace boost;
-#endif
+ // Test int_t and unint_t first:
+ if(std::numeric_limits::is_specialized)
+ do_test_bits::digits>();
+ else
+ do_test_bits::digits>();
- SHOW_TYPES( int_t, least );
- SHOW_TYPES( int_t, fast );
- SHOW_TYPES( uint_t, least );
- SHOW_TYPES( uint_t, fast );
- SHOW_POS_SHIFTED_TYPES( int_max_value_t, least );
- SHOW_POS_SHIFTED_TYPES( int_max_value_t, fast );
- SHOW_NEG_SHIFTED_TYPES( int_min_value_t, least );
- SHOW_NEG_SHIFTED_TYPES( int_min_value_t, fast );
- SHOW_SHIFTED_TYPES( uint_value_t, least );
- SHOW_SHIFTED_TYPES( uint_value_t, fast );
-
- PRIVATE_FIT_TESTS( int_t, least, long, LONG_MAX );
- PRIVATE_FIT_TESTS( int_t, fast, long, LONG_MAX );
- PRIVATE_FIT_TESTS( uint_t, least, unsigned long, ULONG_MAX );
- PRIVATE_FIT_TESTS( uint_t, fast, unsigned long, ULONG_MAX );
- PRIVATE_POS_FIT_TESTS( int_max_value_t, least, long, LONG_MAX );
- PRIVATE_POS_FIT_TESTS( int_max_value_t, fast, long, LONG_MAX );
- PRIVATE_NEG_FIT_TESTS( int_min_value_t, least, long, LONG_MIN );
- PRIVATE_NEG_FIT_TESTS( int_min_value_t, fast, long, LONG_MIN );
- PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, least, unsigned long, ULONG_MAX );
- PRIVATE_SHIFTED_FIT_TESTS( uint_value_t, fast, unsigned long, ULONG_MAX );
-
- return boost::exit_success;
+ //
+ // Test min and max value types:
+ //
+ test_min_max_type, signed char>(SCHAR_MAX);
+ test_min_max_type, signed char>(SCHAR_MIN);
+ test_min_max_type, unsigned char>(UCHAR_MAX);
+#if(USHRT_MAX != UCHAR_MAX)
+ test_min_max_type, short>(SCHAR_MAX+1);
+ test_min_max_type, short>(SCHAR_MIN-1);
+ test_min_max_type, unsigned short>(UCHAR_MAX+1);
+ test_min_max_type, short>(SHRT_MAX);
+ test_min_max_type, short>(SHRT_MIN);
+ test_min_max_type, unsigned short>(USHRT_MAX);
+#endif
+#if(UINT_MAX != USHRT_MAX)
+ test_min_max_type, int>(SHRT_MAX+1);
+ test_min_max_type, int>(SHRT_MIN-1);
+ test_min_max_type, unsigned int>(USHRT_MAX+1);
+ test_min_max_type, int>(INT_MAX);
+ test_min_max_type, int>(INT_MIN);
+ test_min_max_type, unsigned int>(UINT_MAX);
+#endif
+#if(ULONG_MAX != UINT_MAX)
+ test_min_max_type, long>(INT_MAX+1L);
+ test_min_max_type, long>(INT_MIN-1L);
+ test_min_max_type, unsigned long>(UINT_MAX+1uL);
+ test_min_max_type, long>(LONG_MAX);
+ test_min_max_type, long>(LONG_MIN);
+ test_min_max_type, unsigned long>(ULONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULLONG_MAX) && (ULLONG_MAX != ULONG_MAX))
+ test_min_max_type, long long>(LONG_MAX+1LL);
+ test_min_max_type, long long>(LONG_MIN-1LL);
+ test_min_max_type, unsigned long long>(ULONG_MAX+1uLL);
+ test_min_max_type, long long>(LLONG_MAX);
+ test_min_max_type, long long>(LLONG_MIN);
+ test_min_max_type, unsigned long long>(ULLONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX != ULONG_MAX))
+ test_min_max_type, long long>(LONG_MAX+1LL);
+ test_min_max_type, long long>(LONG_MIN-1LL);
+ test_min_max_type, unsigned long long>(ULONG_MAX+1uLL);
+ test_min_max_type, long long>(LONG_LONG_MAX);
+ test_min_max_type, long long>(LONG_LONG_MIN);
+ test_min_max_type, unsigned long long>(ULONG_LONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(ULONGLONG_MAX) && (ULONGLONG_MAX != ULONG_MAX))
+ test_min_max_type, long long>(LONG_MAX+1LL);
+ test_min_max_type, long long>(LONG_MIN-1LL);
+ test_min_max_type, unsigned long long>(ULONG_MAX+1uLL);
+ test_min_max_type, long long>(LONGLONG_MAX);
+ test_min_max_type, long long>(LONGLONG_MAX);
+ test_min_max_type, unsigned long long>(ULONGLONG_MAX);
+#endif
+#if defined(BOOST_HAS_LONG_LONG) && (defined(_ULLONG_MAX) && defined(_LLONG_MIN) && (_ULLONG_MAX != ULONG_MAX))
+ test_min_max_type, long long>(LONG_MAX+1LL);
+ test_min_max_type, long long>(LONG_MIN-1LL);
+ test_min_max_type, unsigned long long>(ULONG_MAX+1uLL);
+ test_min_max_type, long long>(_LLONG_MAX);
+ test_min_max_type, long long>(_LLONG_MIN);
+ test_min_max_type, unsigned long long>(_ULLONG_MAX);
+#endif
+ return 0;
}