Compare commits

...

37 Commits

Author SHA1 Message Date
d73551d222 This commit was manufactured by cvs2svn to create tag
'Version_1_33_1'.

[SVN r31916]
2005-12-05 14:04:06 +00:00
df20953a5e QNX 6.3 Momentics w/Dinkumware defines the integer types with slightly different names. So provide the standard names.
[SVN r30865]
2005-09-07 21:52:13 +00:00
9655c23b86 Enable support for Dragonfly BSD
[SVN r30647]
2005-08-24 15:45:17 +00:00
07b0839716 This commit was manufactured by cvs2svn to create branch 'RC_1_33_0'.
[SVN r30300]
2005-07-28 18:22:24 +00:00
8602a17a10 Replace buggy Cygwin INTMAX_C and UINTMAX_C macros
[SVN r29276]
2005-05-30 01:45:13 +00:00
29275d71aa added workaround for duplicate comdat errors in MSVC++ 6.0
[SVN r29186]
2005-05-25 13:43:12 +00:00
9df9a90217 Make PRIVATE_FIT_TESTS() work correctly on 64-bit machines.
[SVN r28779]
2005-05-10 08:40:28 +00:00
65607e3b82 Work around SunPro 5.3 issue
[SVN r28715]
2005-05-07 13:16:49 +00:00
39399de102 WCHAR_MIN is not trustworthy on MacOS X
[SVN r28714]
2005-05-07 13:14:07 +00:00
27aae3b3cb replaced BOOST_TEST
[SVN r27054]
2005-02-03 13:48:49 +00:00
21fe6251ab Fix to ensure that <wchar.h> is included on solaris (thanks to bug report by Caleb Epstein).
[SVN r26542]
2004-12-17 11:56:15 +00:00
07019a8801 Better support for Tru64.
[SVN r25689]
2004-10-12 16:42:58 +00:00
3892592661 c++boost.gif -> boost.png replacement
[SVN r25573]
2004-10-05 15:45:52 +00:00
0935f20c69 Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.
[SVN r24899]
2004-09-04 10:34:49 +00:00
7197caf500 Added Daryle Walker's copyrights as requested.
[SVN r24481]
2004-08-15 10:13:49 +00:00
92a46aac83 Removed boost.org copyright assignments, and reverted to orginal author (as based on cvs history).
[SVN r24402]
2004-08-11 10:59:33 +00:00
c32a045fa4 Removed Boost.org copyrights and replaced with originating authors copyright instead.
[SVN r24372]
2004-08-10 12:53:34 +00:00
0c31aa03f0 Don't #error when doing a release build. Just put out an informative message, and pass the test.
[SVN r24328]
2004-08-07 06:25:20 +00:00
bfc384a435 License update
[SVN r24180]
2004-07-30 04:46:56 +00:00
198530a48d Converted to Boost Software License, Version 1.0
[SVN r24096]
2004-07-27 03:43:34 +00:00
91f511cab4 Licence update
[SVN r24031]
2004-07-25 12:01:00 +00:00
0f84fe35da fixed typo in comment
[SVN r23945]
2004-07-22 09:02:43 +00:00
fa5aba353f - documented the new typedefs
- added a what's new section
- reformatted a bit
- updated license reference


[SVN r23944]
2004-07-22 08:57:45 +00:00
170a352574 new version - more efficient, and with no dependency on numeric_limits<>
[SVN r23829]
2004-07-20 09:49:43 +00:00
4862574bb1 remove minmax hack from win32.hpp and fix all places that could be affected by the minmax macros
[SVN r22394]
2004-02-26 18:27:02 +00:00
f2d22d091f Patches for cstdint support:
cygwin and mingw now use native stdint headers.
default header now compiles in -pedantic -ansi mode with gcc.


[SVN r21728]
2004-01-14 13:30:49 +00:00
1e6ab2dc10 index.htm renamed index.html
[SVN r21231]
2003-12-11 23:31:15 +00:00
a656e7744f Change license message to reference Boost Software License
[SVN r20038]
2003-09-12 17:09:29 +00:00
46fdbba4b8 Added NetBSD patches from Angus Leeming
[SVN r19804]
2003-08-27 10:30:53 +00:00
f2ea03679b Make sure to define __STDC_CONSTANT_MACROS before we include anything
[SVN r19747]
2003-08-23 13:21:30 +00:00
890e28ab67 include <boost/limits.hpp> instead of <limits.h>, fixing a date-time issue on Comeau
[SVN r18499]
2003-05-22 18:09:32 +00:00
1252426554 Added Cray X1 support
[SVN r17022]
2003-01-24 11:57:27 +00:00
19fb03cefe Added Cray support
[SVN r16989]
2003-01-22 12:12:14 +00:00
a9b35df2f8 add or update See www.boost.org comments
[SVN r16708]
2002-12-27 16:51:53 +00:00
49a8d69fe3 minor fix for integer_traits,
changed is_pod.hpp include to is_POD.hpp as a temporary fix


[SVN r15996]
2002-10-27 12:16:39 +00:00
9cc587a7f2 Merged changes from RC_1_29_0 branch
[SVN r15958]
2002-10-21 11:00:50 +00:00
2de1422682 boost/test/minimal.hpp
[SVN r15234]
2002-09-09 11:58:24 +00:00
20 changed files with 516 additions and 283 deletions

View File

@ -9,7 +9,7 @@
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Header
<h1><img src="../../boost.png" alt="boost.png (6897 bytes)" align="center" width="277" height="86">Header
boost/cstdint.hpp&nbsp;</h1>
<p>The header <code><a href="../../boost/cstdint.hpp">&lt;boost/cstdint.hpp&gt;</a></code>
provides the typedef's useful for

View File

@ -1,26 +1,29 @@
// boost cstdint.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 2000. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// 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 for most recent version including documentation.
// 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>
#define __STDC_CONSTANT_MACROS
#include <boost/cstdint.hpp>
#ifdef NDEBUG
#error This test makes no sense with NDEBUG defined
#endif
int main()
{
std::cout << "This test makes no sense with NDEBUG defined.\n";
return 0;
}
#else
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
//
@ -213,5 +216,4 @@ int main()
std::cout << "OK\n";
return 0;
}
#endif

View File

@ -5,7 +5,7 @@
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)"
align="middle" width="277" height="86">Integer Bit Mask Templates</h1>
<p>The class templates in <cite><a href="../../../boost/integer/integer_mask.hpp">&lt;boost/integer/integer_mask.hpp&gt;</a></cite> provide bit masks for a certain bit position or a contiguous-bit pack of a certain size. The types of the masking constants come from the <a href="../integer.htm">integer type selection templates</a> header.</p>

View File

@ -1,73 +1,125 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Binary Logarithm Template</title>
</head>
<body bgcolor="white" text="black">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)"
align="middle" width="277" height="86">Binary Logarithm Template</h1>
<p>The class template in <cite><a href="../../../boost/integer/static_log2.hpp">&lt;boost/integer/static_log2.hpp&gt;</a></cite> determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#demo">Demonstration Program</a></li>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#credits">Credits</a></li>
<li><a href="#whatsnew"><b>What's new</b></a></li>
</ul>
<h2><a name="synopsis">Synopsis</a></h2>
<blockquote><pre>
namespace boost
{
template &lt; unsigned long Value &gt;
struct static_log2
{
static const int value = <em>implementation_defined</em>;
};
typedef <em>implementation-defined</em> static_log2_argument_type;
typedef <em>implementation-defined</em> static_log2_result_type;
template &lt; &gt;
struct static_log2&lt; 0ul &gt;
{
template &lt; static_log2_argument_type arg &gt;
struct static_log2
{
static const static_log2_result_type value = <em>implementation-defined</em>;
};
template &lt; &gt;
struct static_log2&lt; 0 &gt;
{
// The logarithm of zero is undefined.
};
};
} // namespace boost
</pre></blockquote>
<h2><a name="usage">Usage</a></h2>
<p>The <code>boost::static_log2</code> class template takes one template
parameter, a value of type <code>unsigned long</code>. The template
only defines one member, <code>value</code>, that returns the truncated
base-two logarithm of the template parameter.</p>
parameter, a value of type <code>static_log2_argument_type</code>. The template
only defines one member, <code>value</code>, which gives the truncated
base-two logarithm of the template argument.</p>
<p>Since the logarithm of zero, for any base, is undefined, there is a
specialization of <code>static_log2</code> for a template parameter
specialization of <code>static_log2</code> for a template argument
of zero. This specialization has no members, so an attempt to use
the base-two logarithm of zero results in a compile-time error.</p>
<p>Note: <ul>
<li><code>static_log2_argument_type</code> is an <i>unsigned integer
type</i> (C++ standard, 3.9.1p3).</li>
<li><code>static_log2_result_type</code> is an <i>integer type</i>
(C++ standard, 3.9.1p7).</li>
</ul>
<h2><a name="example">Example</a></h2>
<blockquote><pre>
#include &lt;boost/integer/static_log2.hpp&gt;
template &lt; unsigned long Value &gt;
<blockquote><pre>
#include "boost/integer/static_log2.hpp"
template &lt; boost::static_log2_argument_type value &gt;
bool is_it_what()
{
typedef boost::static_log2&lt;Value&gt; lb_type;
typedef boost::static_log2&lt;value&gt; lb_type;
int temp = lb_type::value;
//...
return (temp % 2) != 0;
}
@ -77,47 +129,87 @@ int main()
{
bool temp = is_it_what&lt;2000&gt;();
//...
#if 0
# if 0
temp = is_it_what&lt;0&gt;(); // would give an error
#endif
# endif
//...
temp = is_it_what&lt;24&gt;();
//...
}
</pre></blockquote>
<h2><a name="demo">Demonstration Program</a></h2>
<p>The program <a href="../test/static_log2_test.cpp">static_log2_test.cpp</a>
is a simplistic demonstration of the results from instantiating various
examples of the binary logarithm class template.</p>
<h2><a name="rationale">Rationale</a></h2>
<p>The base-two (binary) logarithm, abbreviated <dfn>lb</dfn>, function
is occasionally used to give order-estimates of computer algorithms.
is occasionally used to give order-estimates of computer algorithms.
The truncated logarithm can be considered the highest power-of-two in a
value, which corresponds to the value's highest set bit (for binary
integers). Sometimes the highest-bit position could be used in generic
programming, which requires the position to be statically (<i>i.e.</i>
at compile-time) available.</p>
<h2><a name="whatsnew">Changes from previous versions:</a></h2>
<ul>
<li><i>New in version 1.32.0:</i><br><br>
The argument type and the result type of <code>boost::static_log2</code>
are now typedef'd. Formerly, they were hardcoded as <code>unsigned long</code>
and <code>int</code> respectively. Please, use the provided typedefs in new
code (and update old code as soon as possible).
</li>
</ul>
<h2><a name="credits">Credits</a></h2>
<p>The author of the Boost binary logarithm class template is <a
href="../../../people/daryle_walker.html">Daryle Walker</a>. Giovanni Bajo
added support for compilers without partial template specialization.</p>
<p>The original version of the Boost binary logarithm class template was
written by <a href="../../../people/daryle_walker.html">Daryle Walker</a>
and then enhanced by Giovanni Bajo with support for compilers without
partial template specialization. The current version was suggested,
together with a reference implementation, by Vesa Karvonen. Gennaro Prota
wrote the actual source file.
</p>
<hr>
<p>Revised May 14, 2002</p>
<p>&copy; Copyright Daryle Walker 2001. Permission to copy, use,
modify, sell and distribute this document is granted provided this
copyright notice appears in all copies. This document is provided
&quot;as is&quot; without express or implied warranty, and with no claim
as to its suitability for any purpose.</p>
<p>Revised July 19, 2004</p>
<p>&copy; Copyright Daryle Walker 2001.<br>
&copy; Copyright Gennaro Prota 2004.</p>
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
<a href="http://www.boost.org/LICENSE_1_0.txt">
http://www.boost.org/LICENSE_1_0.txt</a>)
<br>
</body>
</html>

View File

@ -5,7 +5,7 @@
</head>
<body bgcolor="white" text="black" link="blue" alink="red" vlink="purple">
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
<h1><img src="../../../boost.png" alt="boost.png (6897 bytes)"
align="middle" width="277" height="86">Compile-Time Extrema
Templates</h1>

View File

@ -1,12 +1,13 @@
// boost cstdint.hpp header file ------------------------------------------//
// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Beman Dawes 1999.
// (C) Copyright Jens Mauer 2001
// (C) Copyright John Maddock 2001
// 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 for most recent version including documentation.
// See http://www.boost.org/libs/integer for documentation.
// Revision History
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
@ -35,12 +36,52 @@
// this is triggered with GCC, because it defines __cplusplus < 199707L
# define BOOST_NO_INT64_T
# endif
# elif defined(__FreeBSD__)
# elif defined(__FreeBSD__) || defined(__IBMCPP__)
# include <inttypes.h>
# else
# include <stdint.h>
// There is a bug in Cygwin two _C macros
# if defined(__STDC_CONSTANT_MACROS) && defined(__CYGWIN__)
# undef INTMAX_C
# undef UINTMAX_C
# define INTMAX_C(c) c##LL
# define UINTMAX_C(c) c##ULL
# 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
{
@ -81,8 +122,8 @@ namespace boost
} // namespace boost
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4)
// FreeBSD has an <inttypes.h> that contains much of what we need
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__)
// FreeBSD and Tru64 have an <inttypes.h> that contains much of what we need.
# include <inttypes.h>
namespace boost {
@ -131,7 +172,7 @@ namespace boost {
#else // BOOST_HAS_STDINT_H
# include <limits.h> // implementation artifact; not part of interface
# include <boost/limits.hpp> // implementation artifact; not part of interface
namespace boost
@ -161,12 +202,29 @@ namespace boost
// 16-bit types -----------------------------------------------------------//
# if USHRT_MAX == 0xffff
# if defined(__crayx1)
// The Cray X1 has a 16-bit short, however it is not recommend
// for use in performance critical code.
typedef short int16_t;
typedef short int_least16_t;
typedef int int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned int uint_fast16_t;
# else
typedef short int16_t;
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# endif
# elif (USHRT_MAX == 0xffffffff) && defined(CRAY)
// no 16-bit types on Cray:
typedef short int_least16_t;
typedef short int_fast16_t;
typedef unsigned short uint_least16_t;
typedef unsigned short uint_fast16_t;
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
@ -205,14 +263,14 @@ namespace boost
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
typedef long long int64_t;
typedef long long int_least64_t;
typedef long long int_fast64_t;
typedef unsigned long long uint64_t;
typedef unsigned long long uint_least64_t;
typedef unsigned long long uint_fast64_t;
typedef ::boost::long_long_type intmax_t;
typedef ::boost::ulong_long_type uintmax_t;
typedef ::boost::long_long_type int64_t;
typedef ::boost::long_long_type int_least64_t;
typedef ::boost::long_long_type int_fast64_t;
typedef ::boost::ulong_long_type uint64_t;
typedef ::boost::ulong_long_type uint_least64_t;
typedef ::boost::ulong_long_type uint_fast64_t;
# elif ULONG_MAX != 0xffffffff
@ -228,6 +286,15 @@ namespace boost
# else
# error defaults not correct; you must hand modify boost/cstdint.hpp
# endif
# elif defined(__GNUC__) && defined(BOOST_HAS_LONG_LONG)
__extension__ typedef long long intmax_t;
__extension__ typedef unsigned long long uintmax_t;
__extension__ typedef long long int64_t;
__extension__ typedef long long int_least64_t;
__extension__ typedef long long int_fast64_t;
__extension__ typedef unsigned long long uint64_t;
__extension__ typedef unsigned long long uint_least64_t;
__extension__ typedef unsigned long long uint_fast64_t;
# elif defined(BOOST_HAS_MS_INT64)
//
// we have Borland/Intel/Microsoft __int64:
@ -374,3 +441,5 @@ BOOST_HAS_STDINT_H is defined (John Maddock).
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.

View File

@ -1,12 +1,10 @@
// boost integer.hpp header file -------------------------------------------//
// (C) Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// Copyright Beman Dawes and Daryle Walker 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 for most recent version including documentation.
// See http://www.boost.org/libs/integer for documentation.
// Revision History
// 22 Sep 01 Added value-based integer templates. (Daryle Walker)

View File

@ -1,9 +1,9 @@
// Boost integer/integer_mask.hpp header file ------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.
// (C) Copyright Daryle Walker 2001.
// 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 for updates, documentation, and revision history.

View File

@ -1,141 +1,132 @@
// Boost integer/static_log2.hpp header file -------------------------------//
// -------------- Boost static_log2.hpp header file ----------------------- //
//
// Copyright (C) 2001 Daryle Walker.
// Copyright (C) 2003 Vesa Karvonen.
// Copyright (C) 2003 Gennaro Prota.
//
// 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.
// ------------------------------------------------------------------------- //
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell and
// distribute this software is granted provided this copyright notice appears
// in all copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any purpose.
// See http://www.boost.org for updates, documentation, and revision history.
#ifndef BOOST_INTEGER_STATIC_LOG2_HPP
#define BOOST_INTEGER_STATIC_LOG2_HPP
#include <boost/integer_fwd.hpp> // self include
#include "boost/config.hpp" // for BOOST_STATIC_CONSTANT
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT, etc.
#include <boost/limits.hpp> // for std::numeric_limits
namespace boost {
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/pending/ct_if.hpp> // for boost::ct_if<>
#endif
namespace detail {
namespace static_log2_impl {
// choose_initial_n<>
//
// Recursively doubles its integer argument, until it
// becomes >= of the "width" (C99, 6.2.6.2p4) of
// static_log2_argument_type.
//
// Used to get the maximum power of two less then the width.
//
// Example: if on your platform argument_type has 48 value
// bits it yields n=32.
//
// It's easy to prove that, starting from such a value
// of n, the core algorithm works correctly for any width
// of static_log2_argument_type and that recursion always
// terminates with x = 1 and n = 0 (see the algorithm's
// invariant).
typedef unsigned long argument_type;
typedef int result_type;
namespace boost
{
template <result_type n>
struct choose_initial_n {
enum { c = (argument_type(1) << n << n) != 0 };
BOOST_STATIC_CONSTANT(
result_type,
value = !c*n + choose_initial_n<2*c*n>::value
);
};
template <>
struct choose_initial_n<0> {
BOOST_STATIC_CONSTANT(result_type, value = 0);
};
// Implementation details --------------------------------------------------//
namespace detail
{
// start computing from n_zero - must be a power of two
const result_type n_zero = 16;
const result_type initial_n = choose_initial_n<n_zero>::value;
// Forward declarations
template < unsigned long Val, int Place = 0, int Index
= std::numeric_limits<unsigned long>::digits >
struct static_log2_helper_t;
// static_log2_impl<>
//
// * Invariant:
// 2n
// 1 <= x && x < 2 at the start of each recursion
// (see also choose_initial_n<>)
//
// * Type requirements:
//
// argument_type maybe any unsigned type with at least n_zero + 1
// value bits. (Note: If larger types will be standardized -e.g.
// unsigned long long- then the argument_type typedef can be
// changed without affecting the rest of the code.)
//
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <argument_type x, result_type n = initial_n>
struct static_log2_impl {
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >;
enum { c = (x >> n) > 0 }; // x >= 2**n ?
BOOST_STATIC_CONSTANT(
result_type,
value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value)
);
#else
};
template < int Place >
struct static_log2_helper_final_step;
template <>
struct static_log2_impl<1, 0> {
BOOST_STATIC_CONSTANT(result_type, value = 0);
};
template < unsigned long Val, int Place = 0, int Index
= std::numeric_limits<unsigned long>::digits >
struct static_log2_helper_nopts_t;
#endif
// Recursively build the logarithm by examining the upper bits
template < unsigned long Val, int Place, int Index >
struct static_log2_helper_t
{
private:
BOOST_STATIC_CONSTANT( int, half_place = Index / 2 );
BOOST_STATIC_CONSTANT( unsigned long, lower_mask = (1ul << half_place)
- 1ul );
BOOST_STATIC_CONSTANT( unsigned long, upper_mask = ~lower_mask );
BOOST_STATIC_CONSTANT( bool, do_shift = (Val & upper_mask) != 0ul );
BOOST_STATIC_CONSTANT( unsigned long, new_val = do_shift ? (Val
>> half_place) : Val );
BOOST_STATIC_CONSTANT( int, new_place = do_shift ? (Place + half_place)
: Place );
BOOST_STATIC_CONSTANT( int, new_index = Index - half_place );
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef static_log2_helper_t<new_val, new_place, new_index> next_step_type;
#else
typedef static_log2_helper_nopts_t<new_val, new_place, new_index> next_step_type;
#endif
public:
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
}; // boost::detail::static_log2_helper_t
// Non-recursive case
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template < unsigned long Val, int Place >
struct static_log2_helper_t< Val, Place, 1 >
{
public:
BOOST_STATIC_CONSTANT( int, value = Place );
}; // boost::detail::static_log2_helper_t
#else
template < int Place >
struct static_log2_helper_final_step
{
public:
BOOST_STATIC_CONSTANT( int, value = Place );
}; // boost::detail::static_log2_helper_final_step
template < unsigned long Val, int Place, int Index >
struct static_log2_helper_nopts_t
{
private:
typedef static_log2_helper_t<Val, Place, Index> recursive_step_type;
typedef static_log2_helper_final_step<Place> final_step_type;
typedef typename ct_if<( Index != 1 ), recursive_step_type,
final_step_type>::type next_step_type;
public:
BOOST_STATIC_CONSTANT( int, value = next_step_type::value );
}; // boost::detail::static_log2_helper_nopts_t
#endif
} // namespace detail
}
} // detail
// Compile-time log-base-2 evaluator class declaration ---------------------//
template < unsigned long Value >
struct static_log2
{
BOOST_STATIC_CONSTANT( int, value
= detail::static_log2_helper_t<Value>::value );
};
// --------------------------------------
// static_log2<x>
// ----------------------------------------
template < >
struct static_log2< 0ul >
{
// The logarithm of zero is undefined.
};
typedef detail::static_log2_impl::argument_type static_log2_argument_type;
typedef detail::static_log2_impl::result_type static_log2_result_type;
} // namespace boost
template <static_log2_argument_type x>
struct static_log2 {
BOOST_STATIC_CONSTANT(
static_log2_result_type,
value = detail::static_log2_impl::static_log2_impl<x>::value
);
};
#endif // BOOST_INTEGER_STATIC_LOG2_HPP
template <>
struct static_log2<0> { };
}
#endif // include guard

View File

@ -1,10 +1,9 @@
// Boost integer/static_min_max.hpp header file ----------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright notice
// appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability
// for any purpose.
// (C) Copyright Daryle Walker 2001.
// 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 for updates, documentation, and revision history.

View File

@ -1,12 +1,10 @@
// Boost integer_fwd.hpp header file ---------------------------------------//
// (C) Copyright boost.org 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Dave Abrahams and Daryle Walker 2001. 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 for most recent version including documentation.
// See http://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_FWD_HPP
#define BOOST_INTEGER_FWD_HPP
@ -69,10 +67,10 @@ template < >
#ifdef ULLONG_MAX
template < >
class integer_traits< long long >;
class integer_traits< ::boost::long_long_type>;
template < >
class integer_traits< unsigned long long >;
class integer_traits< ::boost::ulong_long_type >;
#endif

View File

@ -1,20 +1,18 @@
/* boost integer_traits.hpp header file
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
* Jens Maurer makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
* 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$
*
* Idea by Beman Dawes, Ed Brey, Steve Cleary, and Nathan Myers
*/
// See http://www.boost.org/libs/integer for documentation.
#ifndef BOOST_INTEGER_TRAITS_HPP
#define BOOST_INTEGER_TRAITS_HPP
@ -23,7 +21,9 @@
// These are an implementation detail and not part of the interface
#include <limits.h>
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR)
// we need wchar.h for WCHAR_MAX/MIN but not all platforms provide it,
// and some may have <wchar.h> but not <cwchar> ...
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && (!defined(BOOST_NO_CWCHAR) || defined(sun) || defined(__sun))
#include <wchar.h>
#endif
@ -88,17 +88,25 @@ class integer_traits<unsigned char>
template<>
class integer_traits<wchar_t>
: public std::numeric_limits<wchar_t>,
#if defined(WCHAR_MIN) && defined(WCHAR_MAX)
// Don't trust WCHAR_MIN and WCHAR_MAX with Mac OS X's native
// library: they are wrong!
#if defined(WCHAR_MIN) && defined(WCHAR_MAX) && !defined(__APPLE__)
public detail::integer_traits_base<wchar_t, WCHAR_MIN, WCHAR_MAX>
#elif defined(__BORLANDC__) || defined(__CYGWIN__) || defined(__MINGW32__) || (defined(__BEOS__) && defined(__GNUC__))
// No WCHAR_MIN and WCHAR_MAX, whar_t is short and unsigned:
public detail::integer_traits_base<wchar_t, 0, 0xffff>
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400)) || (defined __APPLE__) || (defined(__FreeBSD__) && defined(__GNUC__)) || (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
#elif (defined(__sgi) && (!defined(__SGI_STL_PORT) || __SGI_STL_PORT < 0x400))\
|| (defined __APPLE__)\
|| (defined(__OpenBSD__) && defined(__GNUC__))\
|| (defined(__NetBSD__) && defined(__GNUC__))\
|| (defined(__FreeBSD__) && defined(__GNUC__))\
|| (defined(__DragonFly__) && defined(__GNUC__))\
|| (defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 3) && !defined(__SGI_STL_PORT))
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as int.
// - SGI MIPSpro with native library
// - gcc 3.x on HP-UX
// - Mac OS X with native library
// - gcc on FreeBSD
// - gcc on FreeBSD, OpenBSD and NetBSD
public detail::integer_traits_base<wchar_t, INT_MIN, INT_MAX>
#elif defined(__hpux) && defined(__GNUC__) && (__GNUC__ == 2) && !defined(__SGI_STL_PORT)
// No WCHAR_MIN and WCHAR_MAX, wchar_t has the same range as unsigned int.
@ -147,42 +155,82 @@ class integer_traits<unsigned long>
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
{ };
#if defined(ULLONG_MAX) && !defined(__SUNPRO_CC)
#if !defined(BOOST_NO_INTEGRAL_INT64_T) && !defined(BOOST_NO_INT64_T)
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LLONG_MIN, LLONG_MAX>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, LLONG_MIN, LLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULLONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULLONG_MAX>
{ };
#elif defined(ULONG_LONG_MAX)
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONG_LONG_MIN, LONG_LONG_MAX>
{ };
class integer_traits< ::boost::long_long_type> : public std::numeric_limits< ::boost::long_long_type>, public detail::integer_traits_base< ::boost::long_long_type, LONG_LONG_MIN, LONG_LONG_MAX>{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONG_LONG_MAX>
{ };
#elif defined(ULONGLONG_MAX) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits<long long>
: public std::numeric_limits<long long>,
public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, LONGLONG_MIN, LONGLONG_MAX>
{ };
template<>
class integer_traits<unsigned long long>
: public std::numeric_limits<unsigned long long>,
public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ULONGLONG_MAX>
{ };
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
template<>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, -_LLONG_MAX - _C2, _LLONG_MAX>
{ };
template<>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, _ULLONG_MAX>
{ };
#elif defined(BOOST_HAS_LONG_LONG)
//
// we have long long but no constants, this happens for example with gcc in -ansi mode,
// we'll just have to work out the values for ourselves (assumes 2's compliment representation):
//
template<>
class integer_traits< ::boost::long_long_type>
: public std::numeric_limits< ::boost::long_long_type>,
public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) - 1)), ~(1LL << (sizeof(::boost::long_long_type) - 1))>
{ };
template<>
class integer_traits< ::boost::ulong_long_type>
: public std::numeric_limits< ::boost::ulong_long_type>,
public detail::integer_traits_base< ::boost::ulong_long_type, 0, ~0uLL>
{ };
#endif
#endif
} // namespace boost
#endif /* BOOST_INTEGER_TRAITS_HPP */

View File

@ -7,7 +7,7 @@
<body bgcolor="white" text="black">
<table border="1" bgcolor="teal" cellpadding="2">
<tr>
<td bgcolor="white"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
<td bgcolor="white"><img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td>
<td><a href="../../index.htm"><font face="Arial" color="white"><big>Home</big></font></a></td>
<td><a href="../libraries.htm"><font face="Arial" color="white"><big>Libraries</big></font></a></td>
<td><a href="../../people/people.htm"><font face="Arial" color="white"><big>People</big></font></a></td>

View File

@ -6,7 +6,7 @@
<body bgcolor="white" text="black">
<h1>
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
<img src="../../boost.png" alt="boost.png (6897 bytes)"
align="middle" width="277" height="86">Integer Type Selection
Templates</h1>

View File

@ -1,20 +1,18 @@
// boost integer.hpp test program ------------------------------------------//
// (C) Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// 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 for most recent version including documentation.
// 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
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
#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
@ -130,9 +128,27 @@ namespace boost
// Test if a constant can fit within a certain type
#define PRIVATE_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( Template < Number > :: Type ( Value ) == Value )
#define PRIVATE_FIT_TEST(Template, Number, Type, Value) BOOST_CHECK( Template < Number > :: Type ( Value ) == Value )
#define PRIVATE_FIT_TESTS(Template, Type, ValType, InitVal) do { ValType v = InitVal ; PRIVATE_FIT_TEST(Template, 32, Type, v); v >>= 1; \
#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; \
@ -149,8 +165,28 @@ namespace boost
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_TEST( Template < (ULONG_MAX >> Number) > :: Type ( Value ) == Value )
#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; \
@ -170,7 +206,7 @@ namespace boost
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_TEST( Template < (LONG_MAX >> Number) > :: Type ( Value ) == Value )
#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; \
@ -190,7 +226,7 @@ namespace boost
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_TEST( Template < (LONG_MIN >> Number) > :: Type ( Value ) == Value )
#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; \

View File

@ -8,7 +8,7 @@
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Compile-Time Integral
<h1><img src="../../boost.png" alt="boost.png (6897 bytes)" align="center" width="277" height="86">Compile-Time Integral
Type Limits</h1>
<p>

View File

@ -1,14 +1,9 @@
/* boost integer_traits.hpp tests
*
* Copyright Jens Maurer 2000
* Permission to use, copy, modify, sell, and distribute this software
* is hereby granted without fee provided that the above copyright notice
* appears in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation,
*
* Jens Maurer makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
* 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$
*
@ -55,14 +50,22 @@ 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())
<< "; min is " << make_char_numeric_for_streaming((traits::min)())
<< ", max is " << make_char_numeric_for_streaming((traits::max)())
<< std::endl;
BOOST_TEST(traits::is_specialized);
BOOST_TEST(traits::is_integer);
BOOST_TEST(traits::is_integral);
BOOST_TEST(traits::const_min == traits::min());
BOOST_TEST(traits::const_max == traits::max());
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*[])

View File

@ -1,10 +1,9 @@
// boost integer_mask.hpp test program -------------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// 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 for most recent version including documentation.

View File

@ -1,10 +1,9 @@
// Boost static_log2.hpp test program --------------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// 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 for most recent version including documentation.

View File

@ -1,10 +1,9 @@
// Boost static_min_max.hpp test program -----------------------------------//
// (C) Copyright Daryle Walker 2001. Permission to copy, use, modify, sell
// and distribute this software is granted provided this copyright
// notice appears in all copies. This software is provided "as is" without
// express or implied warranty, and with no claim as to its suitability for
// any purpose.
// (C) Copyright Daryle Walker 2001.
// 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 for most recent version including documentation.