mirror of
https://github.com/boostorg/integer.git
synced 2025-06-28 13:30:57 +02:00
Compare commits
2 Commits
svn-branch
...
boost-1.33
Author | SHA1 | Date | |
---|---|---|---|
76e22c436c | |||
07b0839716 |
@ -113,24 +113,10 @@ void integral_constant_type_check(T1, T2)
|
|||||||
assert(sizeof(T1) == sizeof(T2));
|
assert(sizeof(T1) == sizeof(T2));
|
||||||
assert(t1 == t2);
|
assert(t1 == t2);
|
||||||
#endif
|
#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)
|
if(t1 > 0)
|
||||||
assert(t2 > 0);
|
assert(t2 > 0);
|
||||||
else
|
else
|
||||||
assert(!(t2 > 0));
|
assert(!(t2 > 0));
|
||||||
}
|
|
||||||
else if(t1 < 0)
|
|
||||||
assert(!(t2 > 0));
|
|
||||||
#else
|
|
||||||
if(t1 > 0)
|
|
||||||
assert(t2 > 0);
|
|
||||||
else
|
|
||||||
assert(!(t2 > 0));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,9 +202,10 @@ href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
|||||||
|
|
||||||
<p>Revised September 23, 2001</p>
|
<p>Revised September 23, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Daryle Walker 2001. Use, modification, and distribution are
|
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
||||||
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
modify, sell and distribute this document is granted provided this
|
||||||
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
copyright notice appears in all copies. This document is provided
|
||||||
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
"as is" without express or implied warranty, and with no claim
|
||||||
|
as to its suitability for any purpose.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -112,9 +112,10 @@ href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
|||||||
|
|
||||||
<p>Revised October 12, 2001</p>
|
<p>Revised October 12, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Daryle Walker 2001. Use, modification, and distribution are
|
<p>© Copyright Daryle Walker 2001. Permission to copy, use,
|
||||||
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
modify, sell and distribute this document is granted provided this
|
||||||
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
copyright notice appears in all copies. This document is provided
|
||||||
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
"as is" without express or implied warranty, and with no claim
|
||||||
|
as to its suitability for any purpose.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -51,37 +51,6 @@
|
|||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef __QNX__
|
|
||||||
|
|
||||||
// QNX (Dinkumware stdlib) defines these as non-standard names.
|
|
||||||
// Reflect to the standard names.
|
|
||||||
|
|
||||||
typedef ::intleast8_t int_least8_t;
|
|
||||||
typedef ::intfast8_t int_fast8_t;
|
|
||||||
typedef ::uintleast8_t uint_least8_t;
|
|
||||||
typedef ::uintfast8_t uint_fast8_t;
|
|
||||||
|
|
||||||
typedef ::intleast16_t int_least16_t;
|
|
||||||
typedef ::intfast16_t int_fast16_t;
|
|
||||||
typedef ::uintleast16_t uint_least16_t;
|
|
||||||
typedef ::uintfast16_t uint_fast16_t;
|
|
||||||
|
|
||||||
typedef ::intleast32_t int_least32_t;
|
|
||||||
typedef ::intfast32_t int_fast32_t;
|
|
||||||
typedef ::uintleast32_t uint_least32_t;
|
|
||||||
typedef ::uintfast32_t uint_fast32_t;
|
|
||||||
|
|
||||||
# ifndef BOOST_NO_INT64_T
|
|
||||||
|
|
||||||
typedef ::intleast64_t int_least64_t;
|
|
||||||
typedef ::intfast64_t int_fast64_t;
|
|
||||||
typedef ::uintleast64_t uint_least64_t;
|
|
||||||
typedef ::uintfast64_t uint_fast64_t;
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -173,7 +142,6 @@ namespace boost {
|
|||||||
#else // BOOST_HAS_STDINT_H
|
#else // BOOST_HAS_STDINT_H
|
||||||
|
|
||||||
# include <boost/limits.hpp> // implementation artifact; not part of interface
|
# include <boost/limits.hpp> // implementation artifact; not part of interface
|
||||||
# include <limits.h> // needed for limits macros
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
|
// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
|
||||||
// and some may have <wchar.h> but not <cwchar> ...
|
// and some may have <wchar.h> but not <cwchar> ...
|
||||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun) || defined(__QNX__))
|
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun))
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -100,7 +100,6 @@ class integer_traits<wchar_t>
|
|||||||
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|
||||||
|| (defined(__NetBSD__) && defined(__GNUC__))\
|
|| (defined(__NetBSD__) && defined(__GNUC__))\
|
||||||
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|
||||||
|| (defined(__DragonFly__) && defined(__GNUC__))\
|
|
||||||
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
|
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
|
||||||
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
|
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
|
||||||
// - SGI MIPSpro with native library
|
// - SGI MIPSpro with native library
|
||||||
|
@ -204,9 +204,10 @@ value-based sized templates.</p>
|
|||||||
|
|
||||||
<p>Revised May 20, 2001</p>
|
<p>Revised May 20, 2001</p>
|
||||||
|
|
||||||
<p>© Copyright Beman Dawes 1999. Use, modification, and distribution are
|
<p>© Copyright Beman Dawes 1999. Permission to copy, use, modify,
|
||||||
subject to the Boost Software License, Version 1.0. (See accompanying file <a
|
sell and distribute this document is granted provided this copyright
|
||||||
href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a copy at <<a
|
notice appears in all copies. This document is provided "as
|
||||||
href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>>.)</p>
|
is" without express or implied warranty, and with no claim as to
|
||||||
|
its suitability for any purpose.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -19,16 +19,16 @@
|
|||||||
#include <iostream> // for std::cout (std::endl indirectly)
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
|
||||||
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||||
(v) >::high_bit == (1ul << (v)) );
|
(v) >::high_bit == (1ul << (v)) );
|
||||||
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_CHECK( ::boost::high_bit_mask_t< \
|
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||||
(v) >::high_bit_fast == (1ul << (v)) );
|
(v) >::high_bit_fast == (1ul << (v)) );
|
||||||
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
||||||
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
||||||
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
||||||
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_CHECK( ::boost::low_bits_mask_t< \
|
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
||||||
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
||||||
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
||||||
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// Macros to compact code
|
// Macros to compact code
|
||||||
#define PRIVATE_LB_TEST( v, e ) BOOST_CHECK( ::boost::static_log2<v>::value == e )
|
#define PRIVATE_LB_TEST( v, e ) BOOST_TEST( ::boost::static_log2<v>::value == e )
|
||||||
|
|
||||||
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
|
#define PRIVATE_PRINT_LB( v ) ::std::cout << "boost::static_log2<" << (v) \
|
||||||
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// 23 Sep 2001 Initial version (Daryle Walker)
|
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||||
|
|
||||||
#define BOOST_INCLUDE_MAIN
|
#define BOOST_INCLUDE_MAIN
|
||||||
#include <boost/test/test_tools.hpp> // for main, BOOST_CHECK
|
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
|
||||||
|
|
||||||
#include <boost/cstdlib.hpp> // for boost::exit_success
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
||||||
@ -37,57 +37,57 @@ test_main
|
|||||||
// Two positives
|
// Two positives
|
||||||
cout << "Doing tests with two positive values." << endl;
|
cout << "Doing tests with two positive values." << endl;
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min< 9, 14>::value) == 9 );
|
BOOST_TEST( (static_signed_min< 9, 14>::value) == 9 );
|
||||||
BOOST_CHECK( (static_signed_max< 9, 14>::value) == 14 );
|
BOOST_TEST( (static_signed_max< 9, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_signed_min<14, 9>::value) == 9 );
|
BOOST_TEST( (static_signed_min<14, 9>::value) == 9 );
|
||||||
BOOST_CHECK( (static_signed_max<14, 9>::value) == 14 );
|
BOOST_TEST( (static_signed_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
BOOST_CHECK( (static_unsigned_min< 9, 14>::value) == 9 );
|
BOOST_TEST( (static_unsigned_min< 9, 14>::value) == 9 );
|
||||||
BOOST_CHECK( (static_unsigned_max< 9, 14>::value) == 14 );
|
BOOST_TEST( (static_unsigned_max< 9, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_unsigned_min<14, 9>::value) == 9 );
|
BOOST_TEST( (static_unsigned_min<14, 9>::value) == 9 );
|
||||||
BOOST_CHECK( (static_unsigned_max<14, 9>::value) == 14 );
|
BOOST_TEST( (static_unsigned_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
// Two negatives
|
// Two negatives
|
||||||
cout << "Doing tests with two negative values." << endl;
|
cout << "Doing tests with two negative values." << endl;
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min< -8, -101>::value) == -101 );
|
BOOST_TEST( (static_signed_min< -8, -101>::value) == -101 );
|
||||||
BOOST_CHECK( (static_signed_max< -8, -101>::value) == -8 );
|
BOOST_TEST( (static_signed_max< -8, -101>::value) == -8 );
|
||||||
BOOST_CHECK( (static_signed_min<-101, -8>::value) == -101 );
|
BOOST_TEST( (static_signed_min<-101, -8>::value) == -101 );
|
||||||
BOOST_CHECK( (static_signed_max<-101, -8>::value) == -8 );
|
BOOST_TEST( (static_signed_max<-101, -8>::value) == -8 );
|
||||||
|
|
||||||
// With zero
|
// With zero
|
||||||
cout << "Doing tests with zero and a positive or negative value." << endl;
|
cout << "Doing tests with zero and a positive or negative value." << endl;
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min< 0, 14>::value) == 0 );
|
BOOST_TEST( (static_signed_min< 0, 14>::value) == 0 );
|
||||||
BOOST_CHECK( (static_signed_max< 0, 14>::value) == 14 );
|
BOOST_TEST( (static_signed_max< 0, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_signed_min<14, 0>::value) == 0 );
|
BOOST_TEST( (static_signed_min<14, 0>::value) == 0 );
|
||||||
BOOST_CHECK( (static_signed_max<14, 0>::value) == 14 );
|
BOOST_TEST( (static_signed_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
BOOST_CHECK( (static_unsigned_min< 0, 14>::value) == 0 );
|
BOOST_TEST( (static_unsigned_min< 0, 14>::value) == 0 );
|
||||||
BOOST_CHECK( (static_unsigned_max< 0, 14>::value) == 14 );
|
BOOST_TEST( (static_unsigned_max< 0, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_unsigned_min<14, 0>::value) == 0 );
|
BOOST_TEST( (static_unsigned_min<14, 0>::value) == 0 );
|
||||||
BOOST_CHECK( (static_unsigned_max<14, 0>::value) == 14 );
|
BOOST_TEST( (static_unsigned_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min< 0, -101>::value) == -101 );
|
BOOST_TEST( (static_signed_min< 0, -101>::value) == -101 );
|
||||||
BOOST_CHECK( (static_signed_max< 0, -101>::value) == 0 );
|
BOOST_TEST( (static_signed_max< 0, -101>::value) == 0 );
|
||||||
BOOST_CHECK( (static_signed_min<-101, 0>::value) == -101 );
|
BOOST_TEST( (static_signed_min<-101, 0>::value) == -101 );
|
||||||
BOOST_CHECK( (static_signed_max<-101, 0>::value) == 0 );
|
BOOST_TEST( (static_signed_max<-101, 0>::value) == 0 );
|
||||||
|
|
||||||
// With identical
|
// With identical
|
||||||
cout << "Doing tests with two identical values." << endl;
|
cout << "Doing tests with two identical values." << endl;
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min<0, 0>::value) == 0 );
|
BOOST_TEST( (static_signed_min<0, 0>::value) == 0 );
|
||||||
BOOST_CHECK( (static_signed_max<0, 0>::value) == 0 );
|
BOOST_TEST( (static_signed_max<0, 0>::value) == 0 );
|
||||||
BOOST_CHECK( (static_unsigned_min<0, 0>::value) == 0 );
|
BOOST_TEST( (static_unsigned_min<0, 0>::value) == 0 );
|
||||||
BOOST_CHECK( (static_unsigned_max<0, 0>::value) == 0 );
|
BOOST_TEST( (static_unsigned_max<0, 0>::value) == 0 );
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min<14, 14>::value) == 14 );
|
BOOST_TEST( (static_signed_min<14, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_signed_max<14, 14>::value) == 14 );
|
BOOST_TEST( (static_signed_max<14, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_unsigned_min<14, 14>::value) == 14 );
|
BOOST_TEST( (static_unsigned_min<14, 14>::value) == 14 );
|
||||||
BOOST_CHECK( (static_unsigned_max<14, 14>::value) == 14 );
|
BOOST_TEST( (static_unsigned_max<14, 14>::value) == 14 );
|
||||||
|
|
||||||
BOOST_CHECK( (static_signed_min< -101, -101>::value) == -101 );
|
BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
|
||||||
BOOST_CHECK( (static_signed_max< -101, -101>::value) == -101 );
|
BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user