mirror of
https://github.com/boostorg/integer.git
synced 2025-06-26 20:41:33 +02:00
Compare commits
19 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
f793dbeab8 | |||
2d259a4f3e | |||
2fd0675a21 | |||
f041dc0f0a | |||
188cef05a9 | |||
2ae867bcf8 | |||
2fcbc31b77 | |||
4af7660410 | |||
2b7ed6ebf7 | |||
203705fea6 | |||
ed80575830 | |||
f27ad7b337 | |||
55e1796c7a | |||
053be71261 | |||
10e5587b9e | |||
2f91e69629 | |||
422ef1ebe6 | |||
edfaeb6c0e | |||
3c7910fad3 |
@ -1,25 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# This file was automatically generated from the original CMakeLists.txt file
|
||||
# Add a variable to hold the headers for the library
|
||||
set (lib_headers
|
||||
integer.hpp
|
||||
integer_fwd.hpp
|
||||
integer_traits.hpp
|
||||
integer
|
||||
)
|
||||
|
||||
# Add a library target to the build system
|
||||
boost_library_project(
|
||||
integer
|
||||
# SRCDIRS
|
||||
TESTDIRS test
|
||||
HEADERS ${lib_headers}
|
||||
# DOCDIRS
|
||||
DESCRIPTION "The organization of boost integer headers and classes is designed to take advantage of <stdint.h> types from the 1999 C standard without resorting to undefined behavior in terms of the 1998 C++ standard. The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace boost without placing any names in namespace std."
|
||||
MODULARIZED
|
||||
AUTHORS "Beman Dawes <bdawes -at- acm.org>"
|
||||
"Daryle Walker <darylew -at- hotmail.com>"
|
||||
# MAINTAINERS
|
||||
)
|
||||
|
||||
|
233
cstdint_test.cpp
233
cstdint_test.cpp
@ -1,233 +0,0 @@
|
||||
// boost cstdint.hpp test program ------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2000. 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)
|
||||
|
||||
|
||||
// See http://www.boost.org/libs/integer for documentation.
|
||||
|
||||
// Revision History
|
||||
// 11 Sep 01 Adapted to work with macros defined in native stdint.h (John Maddock)
|
||||
// 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
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#ifdef NDEBUG
|
||||
int main()
|
||||
{
|
||||
std::cout << "This test makes no sense with NDEBUG defined.\n";
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
#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.
|
||||
//
|
||||
T1 t1 = static_cast<T1>(-1); // cast suppresses warnings
|
||||
T2 t2 = static_cast<T2>(-1); // ditto
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// 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));
|
||||
#else
|
||||
assert(sizeof(T1) == sizeof(T2));
|
||||
assert(t1 == t2);
|
||||
#endif
|
||||
#if defined(BOOST_HAS_STDINT_H)
|
||||
// native headers are permitted to promote small
|
||||
// unsigned types to type int:
|
||||
if(sizeof(T1) >= sizeof(int))
|
||||
{
|
||||
if(t1 > 0)
|
||||
assert(t2 > 0);
|
||||
else
|
||||
assert(!(t2 > 0));
|
||||
}
|
||||
else if(t1 < 0)
|
||||
assert(!(t2 > 0));
|
||||
#else
|
||||
if(t1 > 0)
|
||||
assert(t2 > 0);
|
||||
else
|
||||
assert(!(t2 > 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
177
include/boost/detail/extended_integer.hpp
Normal file
177
include/boost/detail/extended_integer.hpp
Normal file
@ -0,0 +1,177 @@
|
||||
// Boost detail/extended_integer.hpp header file ----------------------------//
|
||||
|
||||
// (C) Copyright Daryle Walker 2008. Distributed under the Boost Software
|
||||
// License, Version 1.0. (See the accompanying file LICENSE_1_0.txt or a copy
|
||||
// at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
// Encapsulates the double-long and __int64 type families as a single family,
|
||||
// as they are mutually exclusive.
|
||||
|
||||
/** \file
|
||||
\brief Common definition of extended integer types.
|
||||
|
||||
Instead of other Boost headers making separate \#defines for the double-long
|
||||
and __int64 type families, since they're mutually exclusive, make a single
|
||||
set of types and macros for the family that exists (if either).
|
||||
*/
|
||||
|
||||
#ifndef BOOST_DETAIL_EXTENDED_INTEGER_HPP
|
||||
#define BOOST_DETAIL_EXTENDED_INTEGER_HPP
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_HAS_LONG_LONG and BOOST_HAS_MS_INT64
|
||||
|
||||
#include <climits> // for CHAR_BIT, etc.
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
// Extended integer type macro and alias definitions -----------------------//
|
||||
|
||||
// (Unsigned) long long family
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
|
||||
// Existence
|
||||
#define BOOST_HAS_XINT 1
|
||||
|
||||
// Extents
|
||||
#ifdef ULLONG_MAX
|
||||
#define BOOST_XINT_MAX LLONG_MAX
|
||||
#define BOOST_XINT_MIN LLONG_MIN
|
||||
#define BOOST_UXINT_MAX ULLONG_MAX
|
||||
#elif defined(ULONG_LONG_MAX)
|
||||
#define BOOST_XINT_MAX LONG_LONG_MAX
|
||||
#define BOOST_XINT_MIN LONG_LONG_MIN
|
||||
#define BOOST_UXINT_MAX ULONG_LONG_MAX
|
||||
#elif defined(ULONGLONG_MAX)
|
||||
#define BOOST_XINT_MAX LONGLONG_MAX
|
||||
#define BOOST_XINT_MIN LONGLONG_MIN
|
||||
#define BOOST_UXINT_MAX ULONGLONG_MAX
|
||||
#elif defined(_LLONG_MAX) && defined(_C2)
|
||||
#define BOOST_XINT_MAX _LLONG_MAX
|
||||
#define BOOST_XINT_MIN (-_LLONG_MAX - _C2)
|
||||
#define BOOST_UXINT_MAX _ULLONG_MAX
|
||||
#else // guess
|
||||
// Sometimes we get the double-long types without the corresponding constants,
|
||||
// e.g. GCC in "-ansi" mode. In this case, we'll just have to work out the
|
||||
// values ourselves. (Here we assume a two's complement representation.)
|
||||
#define BOOST_XINT_MIN (1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1))
|
||||
#define BOOST_XINT_MAX (~ BOOST_XINT_MIN)
|
||||
#define BOOST_UXINT_MAX (~ 0uLL)
|
||||
#endif
|
||||
|
||||
// Types
|
||||
typedef ::boost:: long_long_type xint_t;
|
||||
typedef ::boost::ulong_long_type uxint_t;
|
||||
|
||||
// (Unsigned) __int64 family
|
||||
#elif defined(BOOST_HAS_MS_INT64)
|
||||
|
||||
// Existence
|
||||
#define BOOST_HAS_XINT 1
|
||||
|
||||
// Extents
|
||||
#ifdef _UI64_MAX
|
||||
#define BOOST_XINT_MAX _I64_MAX
|
||||
#define BOOST_XINT_MIN _I64_MIN
|
||||
#define BOOST_UXINT_MAX _UI64_MAX
|
||||
#else // guess
|
||||
// The types are exactly 2's-compl. 64-bit, so we'll enter the values directly.
|
||||
#define BOOST_XINT_MAX 0x7FFFFFFFFFFFFFFFi64
|
||||
#define BOOST_XINT_MIN 0x8000000000000000i64
|
||||
#define BOOST_UXINT_MAX 0xFFFFFFFFFFFFFFFFui64
|
||||
#endif
|
||||
|
||||
// Types
|
||||
typedef __int64 xint_t;
|
||||
typedef unsigned __int64 uxint_t;
|
||||
|
||||
// Neither
|
||||
#else
|
||||
|
||||
// Non-existence
|
||||
#define BOOST_HAS_XINT 0
|
||||
|
||||
// Dummy extents
|
||||
#define BOOST_XINT_MAX LONG_MAX
|
||||
#define BOOST_XINT_MIN LONG_MIN
|
||||
#define BOOST_UXINT_MAX ULONG_MAX
|
||||
|
||||
// Dummy types
|
||||
typedef signed long xint_t;
|
||||
typedef unsigned long uxint_t;
|
||||
|
||||
#endif // defined(BOOST_HAS_LONG_LONG)/defined(BOOST_HAS_MS_INT64)/else
|
||||
|
||||
/** \def BOOST_HAS_XINT
|
||||
|
||||
\brief Flag for extended integer types.
|
||||
|
||||
Indicates the presence of one of the two common extended integer type
|
||||
families, either (<code>unsigned</code>) <code>long long</code> or
|
||||
(<code>unsigned</code>) <code>__int64</code>. \c BOOST_HAS_XINT is \c 1 if
|
||||
either type family is defined, and \c 0 if neither is.
|
||||
*/
|
||||
|
||||
/** \def BOOST_XINT_MAX
|
||||
|
||||
\brief Maximum value for the signed extended integer type.
|
||||
|
||||
\pre \c BOOST_HAS_XINT is \c \#defined to be \c 1.
|
||||
|
||||
Macro constant representing the largest value the signed extended integer
|
||||
type supports. Its composition may be another macro, an expression, or a
|
||||
literal. Defaulted to \c LONG_MAX if \c BOOST_HAS_XINT is zero.
|
||||
*/
|
||||
/** \def BOOST_XINT_MIN
|
||||
|
||||
\brief Minimum value for the signed extended integer type.
|
||||
|
||||
\pre \c BOOST_HAS_XINT is \c \#defined to be \c 1.
|
||||
|
||||
Macro constant representing the smallest value the signed extended integer
|
||||
type supports. Its composition may be another macro, an expression, or a
|
||||
literal. Defaulted to \c LONG_MIN if \c BOOST_HAS_XINT is zero.
|
||||
*/
|
||||
/** \def BOOST_UXINT_MAX
|
||||
|
||||
\brief Maximum value for the unsigned extended integer type.
|
||||
|
||||
\pre \c BOOST_HAS_XINT is \c \#defined to be \c 1.
|
||||
|
||||
Macro constant representing the largest value the unsigned extended integer
|
||||
type supports. Its composition may be another macro, an expression, or a
|
||||
literal. Defaulted to \c ULONG_MAX if \c BOOST_HAS_XINT is zero. (Use
|
||||
\c 0u for the type's minimum value.)
|
||||
*/
|
||||
|
||||
/** \typedef signed long boost::detail::xint_t
|
||||
|
||||
\brief Alias for the signed extended integer type.
|
||||
|
||||
\pre \c BOOST_HAS_XINT is \c \#defined to be \c 1.
|
||||
|
||||
Alias representing the signed extended integer type, no matter which type
|
||||
family it came from. Defaulted to <code>signed long</code> if
|
||||
\c BOOST_HAS_XINT is zero.
|
||||
*/
|
||||
/** \typedef unsigned long ::boost::detail::uxint_t
|
||||
|
||||
\brief Alias for the signed extended integer type.
|
||||
|
||||
\pre \c BOOST_HAS_XINT is \c \#defined to be \c 1.
|
||||
|
||||
Alias representing the unsigned extended integer type, no matter which type
|
||||
family it came from. Defaulted to <code>unsigned long</code> if
|
||||
\c BOOST_HAS_XINT is zero.
|
||||
*/
|
||||
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_DETAIL_EXTENDED_INTEGER_HPP
|
291
integer_test.cpp
291
integer_test.cpp
@ -1,291 +0,0 @@
|
||||
// boost integer.hpp test program ------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 1999. 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)
|
||||
|
||||
|
||||
// See http://www.boost.org/libs/integer for documentation.
|
||||
|
||||
// Revision History
|
||||
// 04 Oct 01 Added tests for new templates; rewrote code (Daryle Walker)
|
||||
// 10 Mar 01 Boost Test Library now used for tests (Beman Dawes)
|
||||
// 31 Aug 99 Initial version
|
||||
|
||||
#include <boost/test/minimal.hpp> // for main, BOOST_CHECK
|
||||
|
||||
#include <boost/config.hpp> // for BOOST_NO_USING_TEMPLATE
|
||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
|
||||
|
||||
#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
|
||||
#include <iostream> // for std::cout (std::endl indirectly)
|
||||
#include <typeinfo> // for std::type_info
|
||||
|
||||
|
||||
// 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
|
||||
#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 < >
|
||||
struct int_fast_t< short >
|
||||
{
|
||||
typedef long fast;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
#endif
|
||||
|
||||
#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)
|
||||
|
||||
#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
|
||||
#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 )
|
||||
|
||||
|
||||
// Test program
|
||||
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
|
||||
|
||||
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;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/* boost integer_traits.hpp tests
|
||||
*
|
||||
* Copyright Jens Maurer 2000
|
||||
* 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)
|
||||
*
|
||||
* $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 <boost/integer_traits.hpp>
|
||||
// use int64_t instead of long long for better portability
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
|
||||
template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
|
||||
namespace fix{
|
||||
inline int make_char_numeric_for_streaming(char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(signed char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
|
||||
}
|
||||
using namespace fix;
|
||||
#else
|
||||
template<typename T> inline T make_char_numeric_for_streaming(T x) { return x; }
|
||||
inline int make_char_numeric_for_streaming(char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(signed char c) { return c; }
|
||||
inline int make_char_numeric_for_streaming(unsigned char c) { return c; }
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
void runtest(const char * type, T)
|
||||
{
|
||||
typedef boost::integer_traits<T> traits;
|
||||
std::cout << "Checking " << type
|
||||
<< "; min is " << make_char_numeric_for_streaming((traits::min)())
|
||||
<< ", max is " << make_char_numeric_for_streaming((traits::max)())
|
||||
<< std::endl;
|
||||
BOOST_CHECK(traits::is_specialized);
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1200)
|
||||
// MSVC++ 6.0 issues a LNK1179 error (duplicate comdat) when the compiler
|
||||
// generates different symbol names with a very long common prefix:
|
||||
// the dummy "&& true" disambiguates between the symbols generated by this
|
||||
// BOOST_CHECK instantiation and the preceding one.
|
||||
BOOST_CHECK(traits::is_integer && true);
|
||||
#else
|
||||
BOOST_CHECK(traits::is_integer);
|
||||
#endif
|
||||
BOOST_CHECK(traits::is_integral == true);
|
||||
BOOST_CHECK(traits::const_min == (traits::min)());
|
||||
BOOST_CHECK(traits::const_max == (traits::max)());
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
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("wchar_t", wchar_t());
|
||||
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) || BOOST_MSVC > 1300) && !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;
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
boost_test_run(cstdint_test cstdint_test.cpp)
|
||||
boost_test_run(integer_mask_test integer_mask_test.cpp)
|
||||
boost_test_run(integer_test integer_test.cpp)
|
||||
boost_test_run(integer_traits_test integer_traits_test.cpp
|
||||
DEPENDS boost_test_exec_monitor)
|
||||
boost_test_run(issue_2134 issue_2134.cpp)
|
||||
boost_test_run(static_log2_test static_log2_test.cpp)
|
||||
boost_test_run(static_min_max_test static_min_max_test.cpp)
|
33
test/issue_2134.cpp
Normal file
33
test/issue_2134.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// boost Issue #2134 test program ------------------------------------------//
|
||||
|
||||
// Copyright Daryle Walker 2008. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See the accompanying file
|
||||
// LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
// See <http://www.boost.org/libs/integer> for documentation.
|
||||
// See <http://svn.boost.org/trac/boost/ticket/2134> for the issue involved.
|
||||
|
||||
// Revision History
|
||||
// 23 Jul 2008 Initial version
|
||||
|
||||
// Control if the inclusion error is triggered
|
||||
#ifndef CONTROL_INCLUDE_TRAITS
|
||||
#define CONTROL_INCLUDE_TRAITS 1
|
||||
#endif
|
||||
|
||||
#if CONTROL_INCLUDE_TRAITS
|
||||
// This file defines boost::detail::integer_traits.
|
||||
#include <boost/detail/numeric_traits.hpp>
|
||||
#endif
|
||||
|
||||
// This is the file with the issue. It has items within the boost::detail
|
||||
// namespace that referenced an unadorned "integer_traits". This was meant to
|
||||
// refer to boost::integer_traits. However, <boost/detail/numeric_traits.hpp>
|
||||
// defines a boost::detail::integer_traits. If that header is #included before
|
||||
// this one, then b.d.integer_traits (rightfully) took priority, which lead to a
|
||||
// syntax error.
|
||||
#include <boost/integer.hpp>
|
||||
|
||||
|
||||
// Main program, minimal (since this is a compile test)
|
||||
int main() { return 0; }
|
Reference in New Issue
Block a user