mirror of
https://github.com/boostorg/integer.git
synced 2025-06-25 20:11:41 +02:00
Compare commits
69 Commits
boost-1.18
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
fcd3688fcd | |||
344fe9f30a | |||
8ad3bbafbc | |||
cc1183d347 | |||
a9703fa803 | |||
5e26f47535 | |||
57e7ccd494 | |||
c56e4674f8 | |||
41620a14f9 | |||
a42ede713e | |||
92de2f44a0 | |||
59779dec2c | |||
3bb567ad9d | |||
c50993d5d4 | |||
5477a9641c | |||
162c6aefa1 | |||
24e6bfbfaa | |||
ccabb522d0 | |||
0995d0a6fb | |||
5ec8116c34 | |||
4a094c4bcb | |||
a7d2da8d1c | |||
4d2a921dbf | |||
0c758855e4 | |||
3399df597e | |||
a066e242b0 | |||
a635f753a4 | |||
08f30ea46c | |||
292eeb5c90 | |||
8a105dab3f | |||
5b0d514aa4 | |||
eee6dfa4d9 | |||
3bd242ef49 | |||
3db9390efb | |||
c6f3dce91a | |||
3e2b929118 | |||
645f809379 | |||
28ec7fa76c | |||
07505c76f8 | |||
fda46f9780 | |||
125bf3351f | |||
e3702f3abc | |||
c54da75efb | |||
2dd1bee693 | |||
949134726f | |||
b3f587b9f7 | |||
215b4d8ee7 | |||
976c5e6572 | |||
0424bb266e | |||
33abcf7250 | |||
b519841b7f | |||
d1781f09d2 | |||
c1c099c845 | |||
f4c38bdf51 | |||
53005cadc8 | |||
ea4963031a | |||
873879d5ac | |||
d39c7cd327 | |||
37eb749c49 | |||
8084359fda | |||
f544a58f58 | |||
d2c2e49154 | |||
50bd08d542 | |||
b5b41c73db | |||
a22a9a3d80 | |||
21ee723419 | |||
202890e032 | |||
4b2fcb5c36 | |||
35dbbde437 |
@ -69,7 +69,7 @@ representing any value of any signed integer type.</p>
|
|||||||
capable of representing any value of any unsigned integer type.</p>
|
capable of representing any value of any unsigned integer type.</p>
|
||||||
<p>These types are required.</p>
|
<p>These types are required.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->12 Nov 2000<!--webbot bot="Timestamp" endspan i-checksum="15060" -->
|
<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->19 Aug 2001<!--webbot bot="Timestamp" endspan i-checksum="14767" -->
|
||||||
</p>
|
</p>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
|
@ -9,21 +9,12 @@
|
|||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
// Revision History
|
// 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>
|
// 12 Nov 00 Adapted to merged <boost/cstdint.hpp>
|
||||||
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
|
// 23 Sep 00 Added INTXX_C constant macro support + int64_t support (John Maddock).
|
||||||
// 28 Jun 00 Initial version
|
// 28 Jun 00 Initial version
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
//
|
|
||||||
// macros should not be defined by default:
|
|
||||||
//
|
|
||||||
#ifdef INT8_C
|
|
||||||
#error header incorrectly implemented
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// now define the macros:
|
|
||||||
//
|
|
||||||
#define __STDC_CONSTANT_MACROS
|
#define __STDC_CONSTANT_MACROS
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
@ -108,14 +99,21 @@ void integral_constant_type_check(T1, T2)
|
|||||||
// numeric_limits implementations currently
|
// numeric_limits implementations currently
|
||||||
// vary too much, or are incomplete or missing.
|
// 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(sizeof(T1) == sizeof(T2));
|
||||||
T1 t1 = -1;
|
|
||||||
T2 t2 = -1;
|
|
||||||
assert(t1 == t2);
|
assert(t1 == t2);
|
||||||
if(t1 >= 0)
|
#endif
|
||||||
assert(t2 >= 0);
|
if(t1 > 0)
|
||||||
|
assert(t2 > 0);
|
||||||
else
|
else
|
||||||
assert(t2 < 0);
|
assert(!(t2 > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,12 +214,4 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// now verify that constant macros get undef'ed correctly:
|
|
||||||
//
|
|
||||||
#undef __STDC_CONSTANT_MACROS
|
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#ifdef INT8_C
|
|
||||||
#error boost/cstdint.hpp not correctly defined
|
|
||||||
#endif
|
|
||||||
|
211
doc/integer_mask.html
Normal file
211
doc/integer_mask.html
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Integer Bit Mask Templates</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
|
||||||
|
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 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"><boost/integer/integer_mask.hpp></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>
|
||||||
|
|
||||||
|
<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="#single">Single Bit-Mask Class Template</a></li>
|
||||||
|
<li><a href="#group">Group Bit-Mask Class Template</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>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2><a name="synopsis">Synopsis</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
#include <cstddef> <i>// for std::size_t</i>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
template < std::size_t Bit >
|
||||||
|
struct high_bit_mask_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> least;
|
||||||
|
typedef <em>implementation_supplied</em> fast;
|
||||||
|
|
||||||
|
static const least high_bit = <em>implementation_defined</em>;
|
||||||
|
static const fast high_bit_fast = <em>implementation_defined</em>;
|
||||||
|
|
||||||
|
static const std::size_t bit_position = Bit;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template < std::size_t Bits >
|
||||||
|
struct low_bits_mask_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> least;
|
||||||
|
typedef <em>implementation_supplied</em> fast;
|
||||||
|
|
||||||
|
static const least sig_bits = <em>implementation_defined</em>;
|
||||||
|
static const fast sig_bits_fast = <em>implementation_defined</em>;
|
||||||
|
|
||||||
|
static const std::size_t bit_count = Bits;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Specializations for low_bits_mask_t exist for certain bit counts.
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="single">Single Bit-Mask Class Template</a></h2>
|
||||||
|
|
||||||
|
<p>The <code>boost::high_bit_mask_t</code> class template provides
|
||||||
|
constants for bit masks representing the bit at a certain position. The
|
||||||
|
masks are equivalent to the value 2<sup><code>Bit</code></sup>, where
|
||||||
|
<code>Bit</code> is the template parameter. The bit position must be a
|
||||||
|
nonnegative number from zero to <i>Max</i>, where <dfn>Max</dfn> is one
|
||||||
|
less than the number of bits supported by the largest unsigned built-in
|
||||||
|
integral type. The following table describes the members of an
|
||||||
|
instantiation of <code>high_bit_mask_t</code>.</p>
|
||||||
|
|
||||||
|
<table border="1" cellpadding="5">
|
||||||
|
<caption>Members of the <code>boost::high_bit_mask_t</code> Class
|
||||||
|
Template</caption>
|
||||||
|
<tr>
|
||||||
|
<th>Member</th>
|
||||||
|
<th>Meaning</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>least</code></td>
|
||||||
|
<td>The smallest unsigned built-in type that supports the given
|
||||||
|
bit position.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>fast</code></td>
|
||||||
|
<td>The quick-to-manipulate analog of <code>least</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>high_bit</code></td>
|
||||||
|
<td>A <code>least</code> constant of the desired bit-masking
|
||||||
|
value.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>high_bit_fast</code></td>
|
||||||
|
<td>A <code>fast</code> analog of <code>high_bit</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>bit_position</code></td>
|
||||||
|
<td>The value of the template parameter, in case its needed from
|
||||||
|
a renamed instantiation of the class template.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2><a name="group">Group Bit-Mask Class Template</a></h2>
|
||||||
|
|
||||||
|
<p>The <code>boost::low_bits_mask_t</code> class template provides
|
||||||
|
constants for bit masks representing the lowest bits of a certain
|
||||||
|
amount. The masks are equivalent to the value
|
||||||
|
(2<sup><code>Bits</code></sup> - 1), where <code>Bits</code> is the
|
||||||
|
template parameter. The bit amount must be a nonnegative number from
|
||||||
|
zero to <i>Max</i>, where <dfn>Max</dfn> is the number of bits supported
|
||||||
|
by the largest unsigned built-in integral type. The following table
|
||||||
|
describes the members of an instantiation of
|
||||||
|
<code>low_bits_mask_t</code>.</p>
|
||||||
|
|
||||||
|
<table border="1" cellpadding="5">
|
||||||
|
<caption>Members of the <code>boost::low_bits_mask_t</code> Class
|
||||||
|
Template</caption>
|
||||||
|
<tr>
|
||||||
|
<th>Member</th>
|
||||||
|
<th>Meaning</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>least</code></td>
|
||||||
|
<td>The smallest unsigned built-in type that supports the given
|
||||||
|
bit count.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>fast</code></td>
|
||||||
|
<td>The quick-to-manipulate analog of <code>least</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>sig_bits</code></td>
|
||||||
|
<td>A <code>least</code> constant of the desired bit-masking
|
||||||
|
value.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>sig_bits_fast</code></td>
|
||||||
|
<td>A <code>fast</code> analog of <code>sig_bits</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>bit_count</code></td>
|
||||||
|
<td>The value of the template parameter, in case its needed from
|
||||||
|
a renamed instantiation of the class template.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p><strong>Implementation Note</strong><br>
|
||||||
|
When <code>Bits</code> is the exact size of a built-in unsigned type,
|
||||||
|
the implementation has to change to prevent undefined behavior.
|
||||||
|
Therefore, there are specializations of <code>low_bits_mask_t</code> at
|
||||||
|
those bit counts.</p>
|
||||||
|
|
||||||
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
#include <boost/integer/integer_mask.hpp>
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef boost::high_bit_mask_t<29> mask1_type;
|
||||||
|
typedef boost::low_bits_mask_t<15> mask2_type;
|
||||||
|
|
||||||
|
mask1_type::least my_var1;
|
||||||
|
mask2_type::fast my_var2;
|
||||||
|
//...
|
||||||
|
|
||||||
|
my_var1 |= mask1_type::high_bit;
|
||||||
|
my_var2 &= mask2_type::sig_bits_fast;
|
||||||
|
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="demo">Demonstration Program</a></h2>
|
||||||
|
|
||||||
|
<p>The program <a href="../test/integer_mask_test.cpp">integer_mask_test.cpp</a>
|
||||||
|
is a simplistic demonstration of the results from instantiating various
|
||||||
|
examples of the bit mask class templates.</p>
|
||||||
|
|
||||||
|
<h2><a name="rationale">Rationale</a></h2>
|
||||||
|
|
||||||
|
<p>The class templates in this header are an extension of the <a
|
||||||
|
href="../integer.htm">integer type selection class templates</a>. The new
|
||||||
|
class templates provide the same sized types, but also convienent masks
|
||||||
|
to use when extracting the highest or all the significant bits when the
|
||||||
|
containing built-in type contains more bits. This prevents
|
||||||
|
contaimination of values by the higher, unused bits.</p>
|
||||||
|
|
||||||
|
<h2><a name="credits">Credits</a></h2>
|
||||||
|
|
||||||
|
<p>The author of the Boost bit mask class templates is <a
|
||||||
|
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Revised September 23, 2001</p>
|
||||||
|
|
||||||
|
<p>© 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
|
||||||
|
"as is" without express or implied warranty, and with no claim
|
||||||
|
as to its suitability for any purpose.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
123
doc/static_log2.html
Normal file
123
doc/static_log2.html
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<!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)"
|
||||||
|
align="middle" width="277" height="86">Binary Logarithm Template</h1>
|
||||||
|
|
||||||
|
<p>The class template in <cite><a href="../../../boost/integer/static_log2.hpp"><boost/integer/static_log2.hpp></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>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2><a name="synopsis">Synopsis</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
template < unsigned long Value >
|
||||||
|
struct static_log2
|
||||||
|
{
|
||||||
|
static const int value = <em>implementation_defined</em>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < >
|
||||||
|
struct static_log2< 0ul >
|
||||||
|
{
|
||||||
|
// 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>
|
||||||
|
|
||||||
|
<p>Since the logarithm of zero, for any base, is undefined, there is a
|
||||||
|
specialization of <code>static_log2</code> for a template parameter
|
||||||
|
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>
|
||||||
|
|
||||||
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
#include <boost/integer/static_log2.hpp>
|
||||||
|
|
||||||
|
template < unsigned long Value >
|
||||||
|
bool is_it_what()
|
||||||
|
{
|
||||||
|
typedef boost::static_log2<Value> lb_type;
|
||||||
|
|
||||||
|
int temp = lb_type::value;
|
||||||
|
//...
|
||||||
|
|
||||||
|
return (temp % 2) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
bool temp = is_it_what<2000>();
|
||||||
|
//...
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
temp = is_it_what<0>(); // would give an error
|
||||||
|
#endif
|
||||||
|
//...
|
||||||
|
|
||||||
|
temp = is_it_what<24>();
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
</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.
|
||||||
|
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="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>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Revised May 14, 2002</p>
|
||||||
|
|
||||||
|
<p>© 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
|
||||||
|
"as is" without express or implied warranty, and with no claim
|
||||||
|
as to its suitability for any purpose.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
121
doc/static_min_max.html
Normal file
121
doc/static_min_max.html
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Compile-Time Extrema Templates</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body bgcolor="white" text="black" link="blue" alink="red" vlink="purple">
|
||||||
|
<h1><img src="../../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
|
||||||
|
align="middle" width="277" height="86">Compile-Time Extrema
|
||||||
|
Templates</h1>
|
||||||
|
|
||||||
|
<p>The class templates in <cite><a
|
||||||
|
href="../../../boost/integer/static_min_max.hpp"><boost/integer/static_min_max.hpp></a></cite>
|
||||||
|
provide a compile-time evaluation of the minimum or maximum of
|
||||||
|
two integers. These facilities are useful for 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>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2><a name="synopsis">Synopsis</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_min;
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_max;
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_min;
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_max;
|
||||||
|
|
||||||
|
}
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="usage">Usage</a></h2>
|
||||||
|
|
||||||
|
<p>The four class templates provide the combinations for finding the
|
||||||
|
minimum or maximum of two signed or <code>unsigned</code>
|
||||||
|
(<code>long</code>) parameters, <var>Value1</var> and <var>Value2</var>,
|
||||||
|
at compile-time. Each template has a single static data member,
|
||||||
|
<code>value</code>, which is set to the respective minimum or maximum
|
||||||
|
of the template's parameters.</p>
|
||||||
|
|
||||||
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>
|
||||||
|
#include <boost/integer/static_min_max.hpp>
|
||||||
|
|
||||||
|
template < unsigned long AddendSize1, unsigned long AddendSize2 >
|
||||||
|
class adder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static unsigned long const addend1_size = AddendSize1;
|
||||||
|
static unsigned long const addend2_size = AddendSize2;
|
||||||
|
static unsigned long const sum_size = boost::static_unsigned_max<AddendSize1, AddendSize2>::value + 1;
|
||||||
|
|
||||||
|
typedef int addend1_type[ addend1_size ];
|
||||||
|
typedef int addend2_type[ addend2_size ];
|
||||||
|
typedef int sum_type[ sum_size ];
|
||||||
|
|
||||||
|
void operator ()( addend1_type const &a1, addend2_type const &a2, sum_type &s ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int const a1[] = { 0, 4, 3 }; // 340
|
||||||
|
int const a2[] = { 9, 8 }; // 89
|
||||||
|
int s[ 4 ];
|
||||||
|
adder<3,2> obj;
|
||||||
|
|
||||||
|
obj( a1, a2, s ); // 's' should be 429 or { 9, 2, 4, 0 }
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="demo">Demonstration Program</a></h2>
|
||||||
|
|
||||||
|
<p>The program <a
|
||||||
|
href="../test/static_min_max_test.cpp">static_min_max_test.cpp</a> is a
|
||||||
|
simplistic demonstration of various comparisons using the compile-time
|
||||||
|
extrema class templates.</p>
|
||||||
|
|
||||||
|
<h2><a name="rationale">Rationale</a></h2>
|
||||||
|
|
||||||
|
<p>Sometimes the minimum or maximum of several values needs to be found
|
||||||
|
for later compile-time processing, <i>e.g.</i> for a bound for another
|
||||||
|
class template.</p>
|
||||||
|
|
||||||
|
<h2><a name="credits">Credits</a></h2>
|
||||||
|
|
||||||
|
<p>The author of the Boost compile-time extrema class templates is <a
|
||||||
|
href="../../../people/daryle_walker.html">Daryle Walker</a>.</p>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Revised October 12, 2001</p>
|
||||||
|
|
||||||
|
<p>© 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
|
||||||
|
"as is" without express or implied warranty, and with no claim
|
||||||
|
as to its suitability for any purpose.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -9,6 +9,9 @@
|
|||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
// Revision History
|
// Revision History
|
||||||
|
// 31 Oct 01 use BOOST_HAS_LONG_LONG to check for "long long" (Jens M.)
|
||||||
|
// 16 Apr 01 check LONGLONG_MAX when looking for "long long" (Jens Maurer)
|
||||||
|
// 23 Jan 01 prefer "long" over "int" for int32_t and intmax_t (Jens Maurer)
|
||||||
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer)
|
// 12 Nov 00 Merged <boost/stdint.h> (Jens Maurer)
|
||||||
// 23 Sep 00 Added INTXX_C macro support (John Maddock).
|
// 23 Sep 00 Added INTXX_C macro support (John Maddock).
|
||||||
// 22 Sep 00 Better 64-bit support (John Maddock)
|
// 22 Sep 00 Better 64-bit support (John Maddock)
|
||||||
@ -22,9 +25,21 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOOST_SYSTEM_HAS_STDINT_H
|
#ifdef BOOST_HAS_STDINT_H
|
||||||
|
|
||||||
# include <stdint.h> // implementation artifact; not part of interface
|
// The following #include is an implementation artifact; not part of interface.
|
||||||
|
# ifdef __hpux
|
||||||
|
// HP-UX has a vaguely nice <stdint.h> in a non-standard location
|
||||||
|
# include <inttypes.h>
|
||||||
|
# ifdef __STDC_32_MODE__
|
||||||
|
// this is triggered with GCC, because it defines __cplusplus < 199707L
|
||||||
|
# define BOOST_NO_INT64_T
|
||||||
|
# endif
|
||||||
|
# elif defined(__FreeBSD__)
|
||||||
|
# include <inttypes.h>
|
||||||
|
# else
|
||||||
|
# include <stdint.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -66,9 +81,55 @@ namespace boost
|
|||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4)
|
||||||
|
// FreeBSD has an <inttypes.h> that contains much of what we need
|
||||||
|
# include <inttypes.h>
|
||||||
|
|
||||||
#else // BOOST_SYSTEM_HAS_STDINT_H
|
namespace boost {
|
||||||
|
|
||||||
|
using ::int8_t;
|
||||||
|
typedef int8_t int_least8_t;
|
||||||
|
typedef int8_t int_fast8_t;
|
||||||
|
using ::uint8_t;
|
||||||
|
typedef uint8_t uint_least8_t;
|
||||||
|
typedef uint8_t uint_fast8_t;
|
||||||
|
|
||||||
|
using ::int16_t;
|
||||||
|
typedef int16_t int_least16_t;
|
||||||
|
typedef int16_t int_fast16_t;
|
||||||
|
using ::uint16_t;
|
||||||
|
typedef uint16_t uint_least16_t;
|
||||||
|
typedef uint16_t uint_fast16_t;
|
||||||
|
|
||||||
|
using ::int32_t;
|
||||||
|
typedef int32_t int_least32_t;
|
||||||
|
typedef int32_t int_fast32_t;
|
||||||
|
using ::uint32_t;
|
||||||
|
typedef uint32_t uint_least32_t;
|
||||||
|
typedef uint32_t uint_fast32_t;
|
||||||
|
|
||||||
|
# ifndef BOOST_NO_INT64_T
|
||||||
|
|
||||||
|
using ::int64_t;
|
||||||
|
typedef int64_t int_least64_t;
|
||||||
|
typedef int64_t int_fast64_t;
|
||||||
|
using ::uint64_t;
|
||||||
|
typedef uint64_t uint_least64_t;
|
||||||
|
typedef uint64_t uint_fast64_t;
|
||||||
|
|
||||||
|
typedef int64_t intmax_t;
|
||||||
|
typedef uint64_t uintmax_t;
|
||||||
|
|
||||||
|
# else
|
||||||
|
|
||||||
|
typedef int32_t intmax_t;
|
||||||
|
typedef uint32_t uintmax_t;
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#else // BOOST_HAS_STDINT_H
|
||||||
|
|
||||||
# include <limits.h> // implementation artifact; not part of interface
|
# include <limits.h> // implementation artifact; not part of interface
|
||||||
|
|
||||||
@ -112,30 +173,38 @@ namespace boost
|
|||||||
|
|
||||||
// 32-bit types -----------------------------------------------------------//
|
// 32-bit types -----------------------------------------------------------//
|
||||||
|
|
||||||
# if UINT_MAX == 0xffffffff
|
# if ULONG_MAX == 0xffffffff
|
||||||
typedef int int32_t;
|
|
||||||
typedef int int_least32_t;
|
|
||||||
typedef int int_fast32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef unsigned int uint_least32_t;
|
|
||||||
typedef unsigned int uint_fast32_t;
|
|
||||||
# elif ULONG_MAX == 0xffffffff
|
|
||||||
typedef long int32_t;
|
typedef long int32_t;
|
||||||
typedef long int_least32_t;
|
typedef long int_least32_t;
|
||||||
typedef long int_fast32_t;
|
typedef long int_fast32_t;
|
||||||
typedef unsigned long uint32_t;
|
typedef unsigned long uint32_t;
|
||||||
typedef unsigned long uint_least32_t;
|
typedef unsigned long uint_least32_t;
|
||||||
typedef unsigned long uint_fast32_t;
|
typedef unsigned long uint_fast32_t;
|
||||||
|
# elif UINT_MAX == 0xffffffff
|
||||||
|
typedef int int32_t;
|
||||||
|
typedef int int_least32_t;
|
||||||
|
typedef int int_fast32_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef unsigned int uint_least32_t;
|
||||||
|
typedef unsigned int uint_fast32_t;
|
||||||
# else
|
# else
|
||||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
||||||
|
|
||||||
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
|
# if defined(BOOST_HAS_LONG_LONG) && \
|
||||||
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
|
!defined(BOOST_MSVC) && !defined(__BORLANDC__) && \
|
||||||
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
|
(!defined(__GLIBCPP__) || defined(_GLIBCPP_USE_LONG_LONG)) && \
|
||||||
|
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
|
||||||
|
# if defined(__hpux)
|
||||||
|
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
|
||||||
|
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615ULL) || (defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615ULL) || (defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615ULL)
|
||||||
// 2**64 - 1
|
// 2**64 - 1
|
||||||
|
# else
|
||||||
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||||
|
# endif
|
||||||
|
|
||||||
typedef long long intmax_t;
|
typedef long long intmax_t;
|
||||||
typedef unsigned long long uintmax_t;
|
typedef unsigned long long uintmax_t;
|
||||||
typedef long long int64_t;
|
typedef long long int64_t;
|
||||||
@ -144,9 +213,7 @@ namespace boost
|
|||||||
typedef unsigned long long uint64_t;
|
typedef unsigned long long uint64_t;
|
||||||
typedef unsigned long long uint_least64_t;
|
typedef unsigned long long uint_least64_t;
|
||||||
typedef unsigned long long uint_fast64_t;
|
typedef unsigned long long uint_fast64_t;
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
|
||||||
# endif
|
|
||||||
# elif ULONG_MAX != 0xffffffff
|
# elif ULONG_MAX != 0xffffffff
|
||||||
|
|
||||||
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
||||||
@ -161,9 +228,9 @@ namespace boost
|
|||||||
# else
|
# else
|
||||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||||
# endif
|
# endif
|
||||||
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
# elif defined(BOOST_HAS_MS_INT64)
|
||||||
//
|
//
|
||||||
// we have Borland/Microsoft __int64:
|
// we have Borland/Intel/Microsoft __int64:
|
||||||
//
|
//
|
||||||
typedef __int64 intmax_t;
|
typedef __int64 intmax_t;
|
||||||
typedef unsigned __int64 uintmax_t;
|
typedef unsigned __int64 uintmax_t;
|
||||||
@ -182,7 +249,7 @@ namespace boost
|
|||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
#endif // BOOST_SYSTEM_HAS_STDINT_H
|
#endif // BOOST_HAS_STDINT_H
|
||||||
|
|
||||||
#endif // BOOST_CSTDINT_HPP
|
#endif // BOOST_CSTDINT_HPP
|
||||||
|
|
||||||
@ -197,15 +264,17 @@ __STDC_CONSTANT_MACROS is defined.
|
|||||||
Undefine the macros if __STDC_CONSTANT_MACROS is
|
Undefine the macros if __STDC_CONSTANT_MACROS is
|
||||||
not defined and the macros are (cf <cassert>).
|
not defined and the macros are (cf <cassert>).
|
||||||
|
|
||||||
Added 23rd September (John Maddock).
|
Added 23rd September 2000 (John Maddock).
|
||||||
|
Modified 11th September 2001 to be excluded when
|
||||||
|
BOOST_HAS_STDINT_H is defined (John Maddock).
|
||||||
|
|
||||||
******************************************************/
|
******************************************************/
|
||||||
|
|
||||||
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED)
|
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(BOOST_HAS_STDINT_H)
|
||||||
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
# define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
||||||
# if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
# if defined(BOOST_HAS_MS_INT64)
|
||||||
//
|
//
|
||||||
// Borland/Microsoft compilers have width specific suffixes:
|
// Borland/Intel/Microsoft compilers have width specific suffixes:
|
||||||
//
|
//
|
||||||
# define INT8_C(value) value##i8
|
# define INT8_C(value) value##i8
|
||||||
# define INT16_C(value) value##i16
|
# define INT16_C(value) value##i16
|
||||||
@ -252,14 +321,20 @@ Added 23rd September (John Maddock).
|
|||||||
|
|
||||||
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
|
||||||
|
|
||||||
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
|
# if defined(BOOST_HAS_LONG_LONG) && \
|
||||||
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
|
(defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
|
||||||
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
|
|
||||||
# define INT64_C(value) value##LL
|
# if defined(__hpux)
|
||||||
# define UINT64_C(value) value##uLL
|
// HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
|
||||||
|
# elif (defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615U) || \
|
||||||
|
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615U) || \
|
||||||
|
(defined(ULONGLONG_MAX) && ULONGLONG_MAX == 18446744073709551615U)
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
# error defaults not correct; you must hand modify boost/cstdint.hpp
|
||||||
# endif
|
# endif
|
||||||
|
# define INT64_C(value) value##LL
|
||||||
|
# define UINT64_C(value) value##uLL
|
||||||
# elif ULONG_MAX != 0xffffffff
|
# elif ULONG_MAX != 0xffffffff
|
||||||
|
|
||||||
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
||||||
@ -281,7 +356,7 @@ Added 23rd September (John Maddock).
|
|||||||
# endif // Borland/Microsoft specific width suffixes
|
# endif // Borland/Microsoft specific width suffixes
|
||||||
|
|
||||||
|
|
||||||
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS)
|
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS) && !defined(BOOST_HAS_STDINT_H)
|
||||||
//
|
//
|
||||||
// undef all the macros:
|
// undef all the macros:
|
||||||
//
|
//
|
||||||
@ -297,3 +372,5 @@ Added 23rd September (John Maddock).
|
|||||||
# undef UINTMAX_C
|
# undef UINTMAX_C
|
||||||
|
|
||||||
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.
|
#endif // __STDC_CONSTANT_MACROS_DEFINED etc.
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,13 +9,18 @@
|
|||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
// Revision History
|
// Revision History
|
||||||
// 30 Jul 00 Add typename syntax fix (Jens Maurer)
|
// 22 Sep 01 Added value-based integer templates. (Daryle Walker)
|
||||||
|
// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (John Maddock)
|
||||||
|
// 30 Jul 00 Add typename syntax fix (Jens Maurer)
|
||||||
// 28 Aug 99 Initial version
|
// 28 Aug 99 Initial version
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_HPP
|
#ifndef BOOST_INTEGER_HPP
|
||||||
#define BOOST_INTEGER_HPP
|
#define BOOST_INTEGER_HPP
|
||||||
|
|
||||||
#include <limits>
|
#include <boost/integer_fwd.hpp> // self include
|
||||||
|
|
||||||
|
#include <boost/integer_traits.hpp> // for boost::integer_traits
|
||||||
|
#include <boost/limits.hpp> // for std::numeric_limits
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -23,6 +28,7 @@ namespace boost
|
|||||||
// Helper templates ------------------------------------------------------//
|
// Helper templates ------------------------------------------------------//
|
||||||
|
|
||||||
// fast integers from least integers
|
// fast integers from least integers
|
||||||
|
// int_fast_t<> works correctly for unsigned too, in spite of the name.
|
||||||
template< typename LeastInt >
|
template< typename LeastInt >
|
||||||
struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
|
struct int_fast_t { typedef LeastInt fast; }; // imps may specialize
|
||||||
|
|
||||||
@ -31,6 +37,7 @@ namespace boost
|
|||||||
|
|
||||||
// specializatons: 1=long, 2=int, 3=short, 4=signed char,
|
// specializatons: 1=long, 2=int, 3=short, 4=signed char,
|
||||||
// 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned long
|
// 6=unsigned long, 7=unsigned int, 8=unsigned short, 9=unsigned long
|
||||||
|
// no specializations for 0 and 5: requests for a type > long are in error
|
||||||
template<> struct int_least_helper<1> { typedef long least; };
|
template<> struct int_least_helper<1> { typedef long least; };
|
||||||
template<> struct int_least_helper<2> { typedef int least; };
|
template<> struct int_least_helper<2> { typedef int least; };
|
||||||
template<> struct int_least_helper<3> { typedef short least; };
|
template<> struct int_least_helper<3> { typedef short least; };
|
||||||
@ -53,7 +60,7 @@ namespace boost
|
|||||||
(Bits-1 <= std::numeric_limits<short>::digits) +
|
(Bits-1 <= std::numeric_limits<short>::digits) +
|
||||||
(Bits-1 <= std::numeric_limits<signed char>::digits)
|
(Bits-1 <= std::numeric_limits<signed char>::digits)
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef int_fast_t<least>::fast fast;
|
typedef typename int_fast_t<least>::fast fast;
|
||||||
};
|
};
|
||||||
|
|
||||||
// unsigned
|
// unsigned
|
||||||
@ -68,14 +75,55 @@ namespace boost
|
|||||||
(Bits <= std::numeric_limits<unsigned short>::digits) +
|
(Bits <= std::numeric_limits<unsigned short>::digits) +
|
||||||
(Bits <= std::numeric_limits<unsigned char>::digits)
|
(Bits <= std::numeric_limits<unsigned char>::digits)
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef int_fast_t<least>::fast fast;
|
typedef typename int_fast_t<least>::fast fast;
|
||||||
|
// int_fast_t<> works correctly for unsigned too, in spite of the name.
|
||||||
};
|
};
|
||||||
|
|
||||||
// The same dispatching technique can be used to select types based on
|
// integer templates specifying extreme value ----------------------------//
|
||||||
// values. That will be added once boost::integer_traits is available.
|
|
||||||
|
// signed
|
||||||
|
template< long MaxValue > // maximum value to require support
|
||||||
|
struct int_max_value_t
|
||||||
|
{
|
||||||
|
typedef typename int_least_helper
|
||||||
|
<
|
||||||
|
(MaxValue <= integer_traits<long>::const_max) +
|
||||||
|
(MaxValue <= integer_traits<int>::const_max) +
|
||||||
|
(MaxValue <= integer_traits<short>::const_max) +
|
||||||
|
(MaxValue <= integer_traits<signed char>::const_max)
|
||||||
|
>::least least;
|
||||||
|
typedef typename int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< long MinValue > // minimum value to require support
|
||||||
|
struct int_min_value_t
|
||||||
|
{
|
||||||
|
typedef typename int_least_helper
|
||||||
|
<
|
||||||
|
(MinValue >= integer_traits<long>::const_min) +
|
||||||
|
(MinValue >= integer_traits<int>::const_min) +
|
||||||
|
(MinValue >= integer_traits<short>::const_min) +
|
||||||
|
(MinValue >= integer_traits<signed char>::const_min)
|
||||||
|
>::least least;
|
||||||
|
typedef typename int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
// unsigned
|
||||||
|
template< unsigned long Value > // maximum value to require support
|
||||||
|
struct uint_value_t
|
||||||
|
{
|
||||||
|
typedef typename int_least_helper
|
||||||
|
<
|
||||||
|
5 +
|
||||||
|
(Value <= integer_traits<unsigned long>::const_max) +
|
||||||
|
(Value <= integer_traits<unsigned int>::const_max) +
|
||||||
|
(Value <= integer_traits<unsigned short>::const_max) +
|
||||||
|
(Value <= integer_traits<unsigned char>::const_max)
|
||||||
|
>::least least;
|
||||||
|
typedef typename int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // BOOST_INTEGER_HPP
|
#endif // BOOST_INTEGER_HPP
|
||||||
|
|
||||||
|
93
include/boost/integer/integer_mask.hpp
Normal file
93
include/boost/integer/integer_mask.hpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
|
#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
|
||||||
|
#define BOOST_INTEGER_INTEGER_MASK_HPP
|
||||||
|
|
||||||
|
#include <boost/integer_fwd.hpp> // self include
|
||||||
|
|
||||||
|
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||||
|
#include <boost/integer.hpp> // for boost::uint_t
|
||||||
|
|
||||||
|
#include <climits> // for UCHAR_MAX, etc.
|
||||||
|
#include <cstddef> // for std::size_t
|
||||||
|
|
||||||
|
#include <boost/limits.hpp> // for std::numeric_limits
|
||||||
|
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// Specified single-bit mask class declaration -----------------------------//
|
||||||
|
// (Lowest bit starts counting at 0.)
|
||||||
|
|
||||||
|
template < std::size_t Bit >
|
||||||
|
struct high_bit_mask_t
|
||||||
|
{
|
||||||
|
typedef typename uint_t<(Bit + 1)>::least least;
|
||||||
|
typedef typename uint_t<(Bit + 1)>::fast fast;
|
||||||
|
|
||||||
|
BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
|
||||||
|
BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
|
||||||
|
|
||||||
|
BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
|
||||||
|
|
||||||
|
}; // boost::high_bit_mask_t
|
||||||
|
|
||||||
|
|
||||||
|
// Specified bit-block mask class declaration ------------------------------//
|
||||||
|
// Makes masks for the lowest N bits
|
||||||
|
// (Specializations are needed when N fills up a type.)
|
||||||
|
|
||||||
|
template < std::size_t Bits >
|
||||||
|
struct low_bits_mask_t
|
||||||
|
{
|
||||||
|
typedef typename uint_t<Bits>::least least;
|
||||||
|
typedef typename uint_t<Bits>::fast fast;
|
||||||
|
|
||||||
|
BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
|
||||||
|
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
|
||||||
|
|
||||||
|
BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
|
||||||
|
|
||||||
|
}; // boost::low_bits_mask_t
|
||||||
|
|
||||||
|
|
||||||
|
#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type ) \
|
||||||
|
template < > struct low_bits_mask_t< std::numeric_limits<Type>::digits > { \
|
||||||
|
typedef std::numeric_limits<Type> limits_type; \
|
||||||
|
typedef uint_t<limits_type::digits>::least least; \
|
||||||
|
typedef uint_t<limits_type::digits>::fast fast; \
|
||||||
|
BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) ); \
|
||||||
|
BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) ); \
|
||||||
|
BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
|
||||||
|
|
||||||
|
#if USHRT_MAX > UCHAR_MAX
|
||||||
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX > USHRT_MAX
|
||||||
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ULONG_MAX > UINT_MAX
|
||||||
|
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef BOOST_LOW_BITS_MASK_SPECIALIZE
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOST_INTEGER_INTEGER_MASK_HPP
|
141
include/boost/integer/static_log2.hpp
Normal file
141
include/boost/integer/static_log2.hpp
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
// Boost integer/static_log2.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.
|
||||||
|
|
||||||
|
// 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, etc.
|
||||||
|
#include <boost/limits.hpp> // for std::numeric_limits
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
#include <boost/pending/ct_if.hpp> // for boost::ct_if<>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// Implementation details --------------------------------------------------//
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
template < unsigned long Val, int Place = 0, int Index
|
||||||
|
= std::numeric_limits<unsigned long>::digits >
|
||||||
|
struct static_log2_helper_t;
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
|
template < unsigned long Val, int Place >
|
||||||
|
struct static_log2_helper_t< Val, Place, 1 >;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template < int Place >
|
||||||
|
struct static_log2_helper_final_step;
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
// 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 );
|
||||||
|
};
|
||||||
|
|
||||||
|
template < >
|
||||||
|
struct static_log2< 0ul >
|
||||||
|
{
|
||||||
|
// The logarithm of zero is undefined.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOST_INTEGER_STATIC_LOG2_HPP
|
56
include/boost/integer/static_min_max.hpp
Normal file
56
include/boost/integer/static_min_max.hpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for updates, documentation, and revision history.
|
||||||
|
|
||||||
|
#ifndef BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
||||||
|
#define BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
||||||
|
|
||||||
|
#include <boost/integer_fwd.hpp> // self include
|
||||||
|
|
||||||
|
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
|
||||||
|
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// Compile-time extrema class declarations ---------------------------------//
|
||||||
|
// Get the minimum or maximum of two values, signed or unsigned.
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_min
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT( long, value = (Value1 > Value2) ? Value2 : Value1 );
|
||||||
|
};
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_max
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT( long, value = (Value1 < Value2) ? Value2 : Value1 );
|
||||||
|
};
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_min
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT( unsigned long, value
|
||||||
|
= (Value1 > Value2) ? Value2 : Value1 );
|
||||||
|
};
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_max
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT( unsigned long, value
|
||||||
|
= (Value1 < Value2) ? Value2 : Value1 );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOST_INTEGER_STATIC_MIN_MAX_HPP
|
154
include/boost/integer_fwd.hpp
Normal file
154
include/boost/integer_fwd.hpp
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
#ifndef BOOST_INTEGER_FWD_HPP
|
||||||
|
#define BOOST_INTEGER_FWD_HPP
|
||||||
|
|
||||||
|
#include <climits> // for UCHAR_MAX, etc.
|
||||||
|
#include <cstddef> // for std::size_t
|
||||||
|
|
||||||
|
#include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
|
||||||
|
#include <boost/limits.hpp> // for std::numeric_limits
|
||||||
|
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/cstdint.hpp> ------------------------------------------------//
|
||||||
|
|
||||||
|
// Only has typedefs or using statements, with #conditionals
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer_traits.hpp> -----------------------------------------//
|
||||||
|
|
||||||
|
template < class T >
|
||||||
|
class integer_traits;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< bool >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< char >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< signed char >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< unsigned char >;
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||||
|
template < >
|
||||||
|
class integer_traits< wchar_t >;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< short >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< unsigned short >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< int >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< unsigned int >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< long >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< unsigned long >;
|
||||||
|
|
||||||
|
#ifdef ULLONG_MAX
|
||||||
|
template < >
|
||||||
|
class integer_traits< long long >;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
class integer_traits< unsigned long long >;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer.hpp> ------------------------------------------------//
|
||||||
|
|
||||||
|
template < typename LeastInt >
|
||||||
|
struct int_fast_t;
|
||||||
|
|
||||||
|
template< int Bits >
|
||||||
|
struct int_t;
|
||||||
|
|
||||||
|
template< int Bits >
|
||||||
|
struct uint_t;
|
||||||
|
|
||||||
|
template< long MaxValue >
|
||||||
|
struct int_max_value_t;
|
||||||
|
|
||||||
|
template< long MinValue >
|
||||||
|
struct int_min_value_t;
|
||||||
|
|
||||||
|
template< unsigned long Value >
|
||||||
|
struct uint_value_t;
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer/integer_mask.hpp> -----------------------------------//
|
||||||
|
|
||||||
|
template < std::size_t Bit >
|
||||||
|
struct high_bit_mask_t;
|
||||||
|
|
||||||
|
template < std::size_t Bits >
|
||||||
|
struct low_bits_mask_t;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
|
||||||
|
|
||||||
|
#if USHRT_MAX > UCHAR_MAX
|
||||||
|
template < >
|
||||||
|
struct low_bits_mask_t< ::std::numeric_limits<unsigned short>::digits >;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX > USHRT_MAX
|
||||||
|
template < >
|
||||||
|
struct low_bits_mask_t< ::std::numeric_limits<unsigned int>::digits >;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ULONG_MAX > UINT_MAX
|
||||||
|
template < >
|
||||||
|
struct low_bits_mask_t< ::std::numeric_limits<unsigned long>::digits >;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer/static_log2.hpp> ------------------------------------//
|
||||||
|
|
||||||
|
template < unsigned long Value >
|
||||||
|
struct static_log2;
|
||||||
|
|
||||||
|
template < >
|
||||||
|
struct static_log2< 0ul >;
|
||||||
|
|
||||||
|
|
||||||
|
// From <boost/integer/static_min_max.hpp> ---------------------------------//
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_min;
|
||||||
|
|
||||||
|
template < long Value1, long Value2 >
|
||||||
|
struct static_signed_max;
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_min;
|
||||||
|
|
||||||
|
template < unsigned long Value1, unsigned long Value2 >
|
||||||
|
struct static_unsigned_max;
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOST_INTEGER_FWD_HPP
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright Jens Maurer 2000
|
* Copyright Jens Maurer 2000
|
||||||
* Permission to use, copy, modify, sell, and distribute this software
|
* Permission to use, copy, modify, sell, and distribute this software
|
||||||
* is hereby granted without free provided that the above copyright notice
|
* is hereby granted without fee provided that the above copyright notice
|
||||||
* appears in all copies and that both that copyright notice and this
|
* appears in all copies and that both that copyright notice and this
|
||||||
* permission notice appear in supporting documentation,
|
* permission notice appear in supporting documentation,
|
||||||
*
|
*
|
||||||
@ -18,11 +18,14 @@
|
|||||||
#ifndef BOOST_INTEGER_TRAITS_HPP
|
#ifndef BOOST_INTEGER_TRAITS_HPP
|
||||||
#define BOOST_INTEGER_TRAITS_HPP
|
#define BOOST_INTEGER_TRAITS_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/limits.hpp>
|
||||||
|
|
||||||
// This is an implementation detail and not part of the interface
|
// These are an implementation detail and not part of the interface
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) && !defined(BOOST_NO_CWCHAR)
|
||||||
|
#include <wchar.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -30,11 +33,7 @@ template<class T>
|
|||||||
class integer_traits : public std::numeric_limits<T>
|
class integer_traits : public std::numeric_limits<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
BOOST_STATIC_CONSTANT(bool, is_integral = false);
|
||||||
static const bool is_integral = false;
|
|
||||||
#else
|
|
||||||
enum { is_integral = false };
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@ -42,18 +41,23 @@ template<class T, T min_val, T max_val>
|
|||||||
class integer_traits_base
|
class integer_traits_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
BOOST_STATIC_CONSTANT(bool, is_integral = true);
|
||||||
static const bool is_integral = true;
|
BOOST_STATIC_CONSTANT(T, const_min = min_val);
|
||||||
static const T const_min = min_val;
|
BOOST_STATIC_CONSTANT(T, const_max = max_val);
|
||||||
static const T const_max = max_val;
|
|
||||||
#else
|
|
||||||
enum {
|
|
||||||
is_integral = true,
|
|
||||||
const_min = min_val,
|
|
||||||
const_max = max_val
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||||
|
// A definition is required even for integral static constants
|
||||||
|
template<class T, T min_val, T max_val>
|
||||||
|
const bool integer_traits_base<T, min_val, max_val>::is_integral;
|
||||||
|
|
||||||
|
template<class T, T min_val, T max_val>
|
||||||
|
const T integer_traits_base<T, min_val, max_val>::const_min;
|
||||||
|
|
||||||
|
template<class T, T min_val, T max_val>
|
||||||
|
const T integer_traits_base<T, min_val, max_val>::const_max;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@ -80,7 +84,32 @@ class integer_traits<unsigned char>
|
|||||||
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
|
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
// What about wchar_t ?
|
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||||
|
template<>
|
||||||
|
class integer_traits<wchar_t>
|
||||||
|
: public std::numeric_limits<wchar_t>,
|
||||||
|
#if defined(WCHAR_MIN) && defined(WCHAR_MAX)
|
||||||
|
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))
|
||||||
|
// 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
|
||||||
|
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.
|
||||||
|
// - gcc 2.95.x on HP-UX
|
||||||
|
// (also, std::numeric_limits<wchar_t> appears to return the wrong values).
|
||||||
|
public detail::integer_traits_base<wchar_t, 0, UINT_MAX>
|
||||||
|
#else
|
||||||
|
#error No WCHAR_MIN and WCHAR_MAX present, please adjust integer_traits<> for your compiler.
|
||||||
|
#endif
|
||||||
|
{ };
|
||||||
|
#endif // BOOST_NO_INTRINSIC_WCHAR_T
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
class integer_traits<short>
|
class integer_traits<short>
|
||||||
@ -118,7 +147,7 @@ class integer_traits<unsigned long>
|
|||||||
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
|
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
#ifdef ULLONG_MAX
|
#if defined(ULLONG_MAX) && !defined(__SUNPRO_CC)
|
||||||
template<>
|
template<>
|
||||||
class integer_traits<long long>
|
class integer_traits<long long>
|
||||||
: public std::numeric_limits<long long>,
|
: public std::numeric_limits<long long>,
|
||||||
@ -140,8 +169,20 @@ class integer_traits<unsigned long long>
|
|||||||
: public std::numeric_limits<unsigned long long>,
|
: public std::numeric_limits<unsigned long long>,
|
||||||
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
|
public detail::integer_traits_base<unsigned long long, 0, ULONG_LONG_MAX>
|
||||||
{ };
|
{ };
|
||||||
|
#elif defined(ULONGLONG_MAX) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
|
||||||
|
template<>
|
||||||
|
class integer_traits<long long>
|
||||||
|
: public std::numeric_limits<long long>,
|
||||||
|
public detail::integer_traits_base<long long, LONGLONG_MIN, LONGLONG_MAX>
|
||||||
|
{ };
|
||||||
|
template<>
|
||||||
|
class integer_traits<unsigned long long>
|
||||||
|
: public std::numeric_limits<unsigned long long>,
|
||||||
|
public detail::integer_traits_base<unsigned long long, 0, ULONGLONG_MAX>
|
||||||
|
{ };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif /* BOOST_INTEGER_TRAITS_HPP */
|
#endif /* BOOST_INTEGER_TRAITS_HPP */
|
||||||
|
|
||||||
|
@ -1,272 +0,0 @@
|
|||||||
// boost stdint.h 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.
|
|
||||||
|
|
||||||
// See http://www.boost.org for most recent version including documentation.
|
|
||||||
|
|
||||||
// NOTE WELL: This is an implementation of the ISO C Standard (1999) stdint.h
|
|
||||||
// header. C++ programs are advised to use <boost/cstdint.hpp> rather than
|
|
||||||
// this header.
|
|
||||||
|
|
||||||
// NOTE OF OBSOLESCENCE: In general, this header file cannot detect
|
|
||||||
// whether the current translation unit somewhere includes ISO C99
|
|
||||||
// <stdint.h> or not. For example, in case BOOST_SYSTEM_HAS_STDINT_H
|
|
||||||
// is not defined and ISO C99 <stdint.h> has been included before,
|
|
||||||
// this file will re-define ISO C99 reserved file-scope identifiers
|
|
||||||
// such as int8_t (see ISO C99 7.1.3 and 7.18). Defining the macro
|
|
||||||
// BOOST_SYSTEM_HAS_STDINT_H is not sufficient in general, in
|
|
||||||
// particular if a partly conformant <stdint.h> header is available
|
|
||||||
// on the platform, e.g. Comeau C++ with GNU glibc 2.1.2.
|
|
||||||
//
|
|
||||||
// In order to avoid incompatibilities with ISO C99, this header
|
|
||||||
// should not be used at all, and it may be deleted in the future.
|
|
||||||
// C++ programs which require ISO C99 <stdint.h> functionality are
|
|
||||||
// strongly advised to use <boost/cstdint.hpp> instead, which
|
|
||||||
// provides <stdint.h> names in namespace boost, e.g. boost::int8_t.
|
|
||||||
|
|
||||||
|
|
||||||
// Revision History
|
|
||||||
// 12 Nov 00 obsoleted (Jens Maurer)
|
|
||||||
// 23 Sep 00 INTXX_C support added (John Maddock)
|
|
||||||
// 22 Sep 00 64-bit support for Borland & Microsoft compilers (John Maddock)
|
|
||||||
// 8 Aug 99 Initial version (Beman Dawes)
|
|
||||||
|
|
||||||
#ifndef BOOST_STDINT_H
|
|
||||||
#define BOOST_STDINT_H
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_SYSTEM_HAS_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <limits.h> // implementation artifact; not part of interface
|
|
||||||
|
|
||||||
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
|
|
||||||
// platforms. For other systems, they will have to be hand tailored.
|
|
||||||
//
|
|
||||||
// Because the fast types are assumed to be the same as the undecorated types,
|
|
||||||
// it may be possible to hand tailor a more efficient implementation. Such
|
|
||||||
// an optimization may be illusionary; on the Intel x86-family 386 on, for
|
|
||||||
// example, byte arithmetic and load/stores are as fast as "int" sized ones.
|
|
||||||
|
|
||||||
// 8-bit types -------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if UCHAR_MAX == 0xff
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef signed char int_least8_t;
|
|
||||||
typedef signed char int_fast8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned char uint_least8_t;
|
|
||||||
typedef unsigned char uint_fast8_t;
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 16-bit types ------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if USHRT_MAX == 0xffff
|
|
||||||
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;
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 32-bit types ------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if UINT_MAX == 0xffffffff
|
|
||||||
typedef int int32_t;
|
|
||||||
typedef int int_least32_t;
|
|
||||||
typedef int int_fast32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
typedef unsigned int uint_least32_t;
|
|
||||||
typedef unsigned int uint_fast32_t;
|
|
||||||
# elif ULONG_MAX == 0xffffffff
|
|
||||||
typedef long int32_t;
|
|
||||||
typedef long int_least32_t;
|
|
||||||
typedef long int_fast32_t;
|
|
||||||
typedef unsigned long uint32_t;
|
|
||||||
typedef unsigned long uint_least32_t;
|
|
||||||
typedef unsigned long uint_fast32_t;
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 64-bit types + intmax_t and uintmax_t -----------------------------------//
|
|
||||||
|
|
||||||
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
|
|
||||||
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
|
|
||||||
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
|
|
||||||
// 2**64 - 1
|
|
||||||
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;
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
# elif ULONG_MAX != 0xffffffff
|
|
||||||
|
|
||||||
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
|
||||||
typedef long intmax_t;
|
|
||||||
typedef unsigned long uintmax_t;
|
|
||||||
typedef long int64_t;
|
|
||||||
typedef long int_least64_t;
|
|
||||||
typedef long int_fast64_t;
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
typedef unsigned long uint_least64_t;
|
|
||||||
typedef unsigned long uint_fast64_t;
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
|
||||||
//
|
|
||||||
// we have Borland/Microsoft __int64:
|
|
||||||
//
|
|
||||||
typedef __int64 intmax_t;
|
|
||||||
typedef unsigned __int64 uintmax_t;
|
|
||||||
typedef __int64 int64_t;
|
|
||||||
typedef __int64 int_least64_t;
|
|
||||||
typedef __int64 int_fast64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
typedef unsigned __int64 uint_least64_t;
|
|
||||||
typedef unsigned __int64 uint_fast64_t;
|
|
||||||
# else // assume no 64-bit integers
|
|
||||||
#define BOOST_NO_INT64_T
|
|
||||||
typedef int32_t intmax_t;
|
|
||||||
typedef uint32_t uintmax_t;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif // BOOST_SYSTEM_HAS_STDINT_H not defined
|
|
||||||
#endif // BOOST_STDINT_H
|
|
||||||
|
|
||||||
/****************************************************
|
|
||||||
|
|
||||||
Macro definition section:
|
|
||||||
|
|
||||||
Define various INTXX_C macros only if
|
|
||||||
__STDC_CONSTANT_MACROS is defined.
|
|
||||||
|
|
||||||
Undefine the macros if __STDC_CONSTANT_MACROS is
|
|
||||||
not defined and the macros are (cf <cassert>).
|
|
||||||
|
|
||||||
Added 23rd September (John Maddock).
|
|
||||||
|
|
||||||
******************************************************/
|
|
||||||
|
|
||||||
#if defined(__STDC_CONSTANT_MACROS) && !defined(BOOST__STDC_CONSTANT_MACROS_DEFINED)
|
|
||||||
#define BOOST__STDC_CONSTANT_MACROS_DEFINED
|
|
||||||
#if (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
|
||||||
//
|
|
||||||
// Borland/Microsoft compilers have width specific suffixes:
|
|
||||||
//
|
|
||||||
#define INT8_C(value) value##i8
|
|
||||||
#define INT16_C(value) value##i16
|
|
||||||
#define INT32_C(value) value##i32
|
|
||||||
#define INT64_C(value) value##i64
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
// Borland bug: appending ui8 makes the type
|
|
||||||
// a signed char!!!!
|
|
||||||
#define UINT8_C(value) static_cast<unsigned char>(value##u)
|
|
||||||
#else
|
|
||||||
#define UINT8_C(value) value##ui8
|
|
||||||
#endif
|
|
||||||
#define UINT16_C(value) value##ui16
|
|
||||||
#define UINT32_C(value) value##ui32
|
|
||||||
#define UINT64_C(value) value##ui64
|
|
||||||
#define INTMAX_C(value) value##i64
|
|
||||||
#define UINTMAX_C(value) value##ui64
|
|
||||||
|
|
||||||
#else
|
|
||||||
// do it the old fashioned way:
|
|
||||||
// 8-bit types -------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if UCHAR_MAX == 0xff
|
|
||||||
#define INT8_C(value) static_cast<int8_t>(value)
|
|
||||||
#define UINT8_C(value) static_cast<uint8_t>(value##u)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 16-bit types ------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if USHRT_MAX == 0xffff
|
|
||||||
#define INT16_C(value) static_cast<int16_t>(value)
|
|
||||||
#define UINT16_C(value) static_cast<uint16_t>(value##u)
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 32-bit types ------------------------------------------------------------//
|
|
||||||
|
|
||||||
# if UINT_MAX == 0xffffffff
|
|
||||||
#define INT32_C(value) value
|
|
||||||
#define UINT32_C(value) value##u
|
|
||||||
# elif ULONG_MAX == 0xffffffff
|
|
||||||
#define INT32_C(value) value##L
|
|
||||||
#define UINT32_C(value) value##uL
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// 64-bit types + intmax_t and uintmax_t -----------------------------------//
|
|
||||||
|
|
||||||
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX)) && !(defined(_WIN32) && defined(__GNUC__))
|
|
||||||
# if(defined(ULLONG_MAX) && ULLONG_MAX == 18446744073709551615) || \
|
|
||||||
(defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 18446744073709551615)
|
|
||||||
#define INT64_C(value) value##LL
|
|
||||||
#define UINT64_C(value) value##uLL
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
# elif ULONG_MAX != 0xffffffff
|
|
||||||
|
|
||||||
# if ULONG_MAX == 18446744073709551615 // 2**64 - 1
|
|
||||||
#define INT64_C(value) value##L
|
|
||||||
#define UINT64_C(value) value##uL
|
|
||||||
# else
|
|
||||||
# error defaults not correct; you must hand modify boost/stdint.h
|
|
||||||
# endif
|
|
||||||
# elif (defined(BOOST_MSVC) && (BOOST_MSVC >= 1100)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x520))
|
|
||||||
//
|
|
||||||
// we have Borland/Microsoft __int64:
|
|
||||||
//
|
|
||||||
#define INT64_C(value) value##i64
|
|
||||||
#define UINT64_C(value) value##ui64
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#ifdef BOOST_NO_INT64_T
|
|
||||||
#define INTMAX_C(value) INT32_C(value)
|
|
||||||
#define UINTMAX_C(value) UINT32_C(value)
|
|
||||||
#else
|
|
||||||
#define INTMAX_C(value) INT64_C(value)
|
|
||||||
#define UINTMAX_C(value) UINT64_C(value)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // Borland/MS specific
|
|
||||||
|
|
||||||
#elif defined(BOOST__STDC_CONSTANT_MACROS_DEFINED) && !defined(__STDC_CONSTANT_MACROS)
|
|
||||||
//
|
|
||||||
// undef all the macros:
|
|
||||||
//
|
|
||||||
#undef INT8_C
|
|
||||||
#undef INT16_C
|
|
||||||
#undef INT32_C
|
|
||||||
#undef INT64_C
|
|
||||||
#undef UINT8_C
|
|
||||||
#undef UINT16_C
|
|
||||||
#undef UINT32_C
|
|
||||||
#undef UINT64_C
|
|
||||||
#undef INTMAX_C
|
|
||||||
#undef UINTMAX_C
|
|
||||||
|
|
||||||
#endif // constant macros
|
|
||||||
|
|
||||||
|
|
150
index.htm
150
index.htm
@ -1,98 +1,128 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Language" content="en-us">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
|
||||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
|
||||||
<title>Boost Integer Library</title>
|
<title>Boost Integer Library</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#FFFFFF" text="#000000">
|
<body bgcolor="white" text="black">
|
||||||
|
<table border="1" bgcolor="teal" cellpadding="2">
|
||||||
<table border="1" bgcolor="#007F7F" cellpadding="2">
|
<tr>
|
||||||
<tr>
|
<td bgcolor="white"><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" width="277" height="86"></td>
|
||||||
<td bgcolor="#FFFFFF"><img src="../../c++boost.gif" alt="c++boost.gif (8819 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="../../index.htm"><font face="Arial" color="#FFFFFF"><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="../libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries </big></font></a></td>
|
<td><a href="../../people/people.htm"><font face="Arial" color="white"><big>People</big></font></a></td>
|
||||||
<td><a href="../../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People </big></font></a></td>
|
<td><a href="../../more/faq.htm"><font face="Arial" color="white"><big>FAQ</big></font></a></td>
|
||||||
<td><a href="../../more/faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ </big></font></a></td>
|
<td><a href="../../more/index.htm"><font face="Arial" color="white"><big>More</big></font></a></td>
|
||||||
<td><a href="../../more/index.htm"><font face="Arial" color="#FFFFFF"><big>More </big></font></a></td>
|
</tr>
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h1>Boost Integer Library</h1>
|
<h1>Boost Integer Library</h1>
|
||||||
|
|
||||||
<table border="1" cellpadding="5">
|
<table border="1" cellpadding="5">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><b><i>Header / Docs</i></b></td>
|
<th>Header / Docs</th>
|
||||||
<td align="center"><b><i>Contents</i></b></td>
|
<th>Contents</th>
|
||||||
<td align="center"><b><i>Use</i></b></td>
|
<th>Use</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><code><a href="../../boost/cstdint.hpp"><boost/cstdint.hpp><br>
|
<td align="center"><cite><a href="../../boost/integer_fwd.hpp"><boost/integer_fwd.hpp></a></cite></td>
|
||||||
|
<td valign="top">Forward declarations of classes and class templates</td>
|
||||||
|
<td valign="top">When just the name of a class is needed</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><code><a href="../../boost/cstdint.hpp"><boost/cstdint.hpp><br>
|
||||||
</a></code><a href="cstdint.htm"><br>
|
</a></code><a href="cstdint.htm"><br>
|
||||||
documentation</a>
|
documentation</a>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top">Typedef's based on the 1999 C Standard header <<code>stdint.h></code>, wrapped in namespace boost.
|
<td valign="top">Typedef's based on the 1999 C Standard header <<code>stdint.h></code>, wrapped in namespace boost.
|
||||||
This implementation may #include the compiler
|
This implementation may #include the compiler
|
||||||
supplied <<code>stdint.h></code>, if present. </td>
|
supplied <<code>stdint.h></code>, if present. </td>
|
||||||
<td valign="top">Supplies typedefs for standard integer types such as <code> int32_t</code> or <code>uint_least16_t</code>.
|
<td valign="top">Supplies typedefs for standard integer types such as <code> int32_t</code> or <code>uint_least16_t</code>.
|
||||||
Use in preference to <<code>stdint.h></code>
|
Use in preference to <<code>stdint.h></code>
|
||||||
for enhanced portability. Furthermore, all names are safely placed in the boost namespace.</td>
|
for enhanced portability. Furthermore, all names are safely placed in the boost namespace.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><code><a href="../../boost/integer_traits.hpp"><boost/integer_traits.hpp></a></code><br>
|
<td align="center"><code><a href="../../boost/integer_traits.hpp"><boost/integer_traits.hpp></a></code><br>
|
||||||
<br>
|
<br>
|
||||||
<a href="integer_traits.html">documentation</a>
|
<a href="integer_traits.html">documentation</a>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top">Template class <code>boost::integer_traits</code>, derived from <code>std::numeric_limits</code>.
|
<td valign="top">Template class <code>boost::integer_traits</code>, derived from <code>std::numeric_limits</code>.
|
||||||
Adds <code>const_min</code> and <code>const_max</code> members.</td>
|
Adds <code>const_min</code> and <code>const_max</code> members.</td>
|
||||||
<td valign="top">Use to obtain the characteristics of a known integer type.</td>
|
<td valign="top">Use to obtain the characteristics of a known integer type.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><code><a href="../../boost/integer.hpp"><boost/integer.hpp></a><br>
|
<td align="center"><code><a href="../../boost/integer.hpp"><boost/integer.hpp></a><br>
|
||||||
<br>
|
<br>
|
||||||
</code><a href="integer.htm">documentation</a></td>
|
</code><a href="integer.htm">documentation</a></td>
|
||||||
<td valign="top">Templates for integer type selection based on properties such as
|
<td valign="top">Templates for integer type selection based on properties such as
|
||||||
maximum value or number of bits.</td>
|
maximum value or number of bits.</td>
|
||||||
<td valign="top">Use to select the type an integer when some property such as maximum value or number of bits is known.
|
<td valign="top">Use to select the type an integer when some property such as maximum value or number of bits is known.
|
||||||
Useful for generic programming. </td>
|
Useful for generic programming. </td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><code><a href="../../boost/integer/integer_mask.hpp"><boost/integer/integer_mask.hpp></a><br>
|
||||||
|
<br>
|
||||||
|
</code><a href="doc/integer_mask.html">documentation</a></td>
|
||||||
|
<td valign="top">Templates for the selection of integer masks, single or lowest group, based on the number of bits.</td>
|
||||||
|
<td valign="top">Use to select a particular mask when the bit position(s) are based on a compile-time variable.
|
||||||
|
Useful for generic programming. </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><code><a href="../../boost/integer/static_log2.hpp"><boost/integer/static_log2.hpp></a><br>
|
||||||
|
<br>
|
||||||
|
</code><a href="doc/static_log2.html">documentation</a></td>
|
||||||
|
<td valign="top">Template for finding the highest power of two in a number.</td>
|
||||||
|
<td valign="top">Use to find the bit-size/range based on a maximum value.
|
||||||
|
Useful for generic programming. </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center"><code><a href="../../boost/integer/static_min_max.hpp"><boost/integer/static_min_max.hpp></a><br>
|
||||||
|
<br>
|
||||||
|
</code><a href="doc/static_min_max.html">documentation</a></td>
|
||||||
|
<td valign="top">Templates for finding the extrema of two numbers.</td>
|
||||||
|
<td valign="top">Use to find a bound based on a minimum or maximum value.
|
||||||
|
Useful for generic programming. </td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Rationale</h2>
|
<h2>Rationale</h2>
|
||||||
<p>The organization of boost integer headers and classes is designed to take
|
|
||||||
advantage of <code><stdint.h></code> types from the 1999 C standard
|
|
||||||
without resorting to undefined behavior in terms of
|
|
||||||
the 1998 C++ standard. The header <code><boost/cstdint.hpp></code>
|
|
||||||
makes the standard integer types safely available in namespace boost without placing any names in namespace std. As always, the intension is to complement rather than
|
|
||||||
compete with the C++ Standard Library. Should some future C++ standard
|
|
||||||
include <code><stdint.h></code> and <code><cstdint></code>, then <code><boost/cstdint.hpp></code>
|
|
||||||
will continue to function, but will become redundant and may be safely deprecated.</p>
|
|
||||||
<p>Because these are boost headers, their names conform to boost header naming
|
|
||||||
conventions rather than C++ Standard Library header naming conventions.
|
|
||||||
|
|
||||||
<h2>Caveat emptor</h2>
|
<p>The organization of boost integer headers and classes is designed to
|
||||||
<p>As an
|
take advantage of <cite><stdint.h></cite> types from the 1999 C
|
||||||
implementation artifact, certain C <limits.h> macro names may possibly be
|
standard without resorting to undefined behavior in terms of the 1998
|
||||||
visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of
|
C++ standard. The header <cite><boost/cstdint.hpp></cite> makes
|
||||||
any Boost specified interface.
|
the standard integer types safely available in namespace
|
||||||
Use boost:: integer_traits<> or std::numeric_limits<> instead.</p>
|
<code>boost</code> without placing any names in namespace
|
||||||
|
<code>std</code>. As always, the intension is to complement rather than
|
||||||
|
compete with the C++ Standard Library. Should some future C++ standard
|
||||||
|
include <cite><stdint.h></cite> and <cite><cstdint></cite>,
|
||||||
|
then <cite><boost/cstdint.hpp></cite> will continue to function,
|
||||||
|
but will become redundant and may be safely deprecated.</p>
|
||||||
|
|
||||||
<p>
|
<p>Because these are boost headers, their names conform to boost header
|
||||||
As another implementation artifact, certain C
|
naming conventions rather than C++ Standard Library header naming
|
||||||
<code><stdint.h></code> typedef names may possibly be visible in the
|
conventions.</p>
|
||||||
global namespace to users of <code><boost/cstdint.hpp></code>.
|
|
||||||
Don't use these names, they are not part of any Boost specified
|
<h2><i>Caveat emptor</i></h2>
|
||||||
|
|
||||||
|
<p>As an implementation artifact, certain C
|
||||||
|
<cite><limits.h></cite> macro names may possibly be visible to
|
||||||
|
users of <cite><boost/cstdint.hpp></cite>. Don't use these
|
||||||
|
macros; they are not part of any Boost-specified interface. Use
|
||||||
|
<code>boost::integer_traits<></code> or
|
||||||
|
<code>std::numeric_limits<></code> instead.</p>
|
||||||
|
|
||||||
|
<p>As another implementation artifact, certain C
|
||||||
|
<cite><stdint.h></cite> typedef names may possibly be visible in
|
||||||
|
the global namespace to users of <cite><boost/cstdint.hpp></cite>.
|
||||||
|
Don't use these names, they are not part of any Boost-specified
|
||||||
interface. Use the respective names in namespace <code>boost</code>
|
interface. Use the respective names in namespace <code>boost</code>
|
||||||
instead.
|
instead.</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>Revised: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %b %Y" startspan -->12 Nov 2000<!--webbot bot="Timestamp" endspan i-checksum="15233" -->
|
<p>Revised: <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %b %Y" startspan -->03 Oct 2001<!--webbot bot="Timestamp" endspan i-checksum="14373" -->
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
235
integer.htm
235
integer.htm
@ -1,110 +1,213 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
|
||||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
|
||||||
<title>Integer Type Selection Templates</title>
|
<title>Integer Type Selection Templates</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#FFFFFF" text="#000000">
|
<body bgcolor="white" text="black">
|
||||||
|
<h1>
|
||||||
|
<img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)"
|
||||||
|
align="middle" width="277" height="86">Integer Type Selection
|
||||||
|
Templates</h1>
|
||||||
|
|
||||||
<h1><img src="../../c++boost.gif" alt="c++boost.gif (8819 bytes)" align="center" width="277" height="86">Integer
|
<p>The <cite><a
|
||||||
Type Selection Templates</h1>
|
href="../../boost/integer.hpp"><boost/integer.hpp></a></cite> type
|
||||||
<p>The <code><a href="../../boost/integer.hpp"><boost/integer.hpp></a></code>
|
selection templates allow integer types to be selected based on desired
|
||||||
type selection templates allow integer types to be selected based on desired
|
characteristics such as number of bits or maximum value. This facility
|
||||||
characteristics such as number of bits or maximum value. This facility is
|
is particularly useful for solving generic programming problems.</p>
|
||||||
particularly useful for solving generic programming problems.</p>
|
|
||||||
|
|
||||||
<p>The templates <b>int_t<></b> and <b>uint_t<></b> supply typedefs <b>least</b>
|
<h2><a name="contents">Contents</a></h2>
|
||||||
and <b>fast</b>. The <b>least</b> type be the smallest type which holds at
|
|
||||||
least the number of bits (including sign) specified. The <b>fast</b> type will
|
|
||||||
be at least as large as the <b>least</b> type, but may possible be larger.
|
|
||||||
There is no guarantee that the <b>fast</b> type will actually be faster than
|
|
||||||
other possible types.</p>
|
|
||||||
|
|
||||||
<h2>Alternative</h2>
|
<ul>
|
||||||
|
<li><a href="#contents">Contents</a></li>
|
||||||
|
<li><a href="#synopsis">Synopsis</a></li>
|
||||||
|
<li><a href="#easy">Easiest-to-Manipulate Types</a></li>
|
||||||
|
<li><a href="#sized">Sized Types</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="#alternative">Alternative</a></li>
|
||||||
|
<li><a href="#credits">Credits</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<p>If the number of bits required is known beforehand, it may be more
|
<h2><a name="synopsis">Synopsis</a></h2>
|
||||||
appropriate to use the types supplied in <code><a href="../../boost/cstdint.hpp"><boost/cstdint.hpp></a></code>.</p>
|
|
||||||
|
|
||||||
<h2>Synopsis</h2>
|
<blockquote><pre>namespace boost
|
||||||
|
|
||||||
<blockquote>
|
|
||||||
<pre>namespace boost
|
|
||||||
{
|
{
|
||||||
// fast integers from least integers
|
// fast integers from least integers
|
||||||
template< typename LeastInt > // Required: LeastInt is integral type, not bool
|
template< typename LeastInt >
|
||||||
struct int_fast_t { typedef LeastInt fast; }; // implementations may specialize
|
struct int_fast_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> fast;
|
||||||
|
};
|
||||||
|
|
||||||
// signed
|
// signed
|
||||||
template< int Bits > // bits (including sign) required, 0-32 valid
|
template< int Bits >
|
||||||
struct int_t
|
struct int_t
|
||||||
{
|
{
|
||||||
typedef <i>implementation-supplied</i> least;
|
typedef <em>implementation_supplied</em> least;
|
||||||
typedef int_fast_t<least>::fast fast;
|
typedef int_fast_t<least>::fast fast;
|
||||||
};
|
};
|
||||||
|
|
||||||
// unsigned
|
// unsigned
|
||||||
template< int Bits > // bits required, 0-32 valid
|
template< int Bits >
|
||||||
struct uint_t
|
struct uint_t
|
||||||
{
|
{
|
||||||
typedef <i>implementation-supplied</i> least;
|
typedef <em>implementation_supplied</em> least;
|
||||||
|
typedef int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
// signed
|
||||||
|
template< long MaxValue >
|
||||||
|
struct int_max_value_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> least;
|
||||||
|
typedef int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< long MinValue >
|
||||||
|
struct int_min_value_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> least;
|
||||||
|
typedef int_fast_t<least>::fast fast;
|
||||||
|
};
|
||||||
|
|
||||||
|
// unsigned
|
||||||
|
template< unsigned long Value >
|
||||||
|
struct uint_value_t
|
||||||
|
{
|
||||||
|
typedef <em>implementation_supplied</em> least;
|
||||||
typedef int_fast_t<least>::fast fast;
|
typedef int_fast_t<least>::fast fast;
|
||||||
};
|
};
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
</pre>
|
</pre></blockquote>
|
||||||
|
|
||||||
</blockquote>
|
<h2><a name="easy">Easiest-to-Manipulate Types</a></h2>
|
||||||
<p>[Templates to select type based on maximum value are under development.]
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h2>Example</h2>
|
<p>The <code>int_fast_t</code> class template maps its input type to the
|
||||||
|
next-largest type that the processor can manipulate the easiest, or to
|
||||||
|
itself if the input type is already an easy-to-manipulate type. For
|
||||||
|
instance, processing a bunch of <code>char</code> objects may go faster
|
||||||
|
if they were converted to <code>int</code> objects before processing.
|
||||||
|
The input type, passed as the only template parameter, must be a
|
||||||
|
built-in integral type, except <code>bool</code>. Unsigned integral
|
||||||
|
types can be used, as well as signed integral types, despite the name.
|
||||||
|
The output type is given as the class member <code>fast</code>.</p>
|
||||||
|
|
||||||
<blockquote>
|
<p><strong>Implementation Notes</strong><br>
|
||||||
<pre>#include <boost/integer.hpp>
|
By default, the output type is identical to the input type. Eventually,
|
||||||
using boost::int_t;
|
this code's implementation should be conditionalized for each platform
|
||||||
|
to give accurate mappings between the built-in types and the
|
||||||
|
easiest-to-manipulate built-in types. Also, there is no guarantee that
|
||||||
|
the output type actually is easier to manipulate than the input
|
||||||
|
type.</p>
|
||||||
|
|
||||||
...
|
<h2><a name="sized">Sized Types</a></h2>
|
||||||
int_t<24>::least my_var; </pre>
|
|
||||||
|
|
||||||
</blockquote>
|
<p>The <code>int_t</code>, <code>uint_t</code>,
|
||||||
<h2>Demonstration Program</h2>
|
<code>int_max_value_t</code>, <code>int_min_value_t</code>, and
|
||||||
|
<code>uint_value_t</code> class templates find the most appropiate
|
||||||
|
built-in integral type for the given template parameter. This type is
|
||||||
|
given by the class member <code>least</code>. The easiest-to-manipulate
|
||||||
|
version of that type is given by the class member <code>fast</code>.
|
||||||
|
The following table describes each template's criteria.</p>
|
||||||
|
|
||||||
<p>The program <a href="integer_test.cpp">integer_test.cpp</a> is a not very
|
<table border="1" cellpadding="5">
|
||||||
smart demonstration of the results from instantiating various <b>int_t<></b>
|
<caption>Criteria for the Sized Type Class Templates</caption>
|
||||||
and <b>uint_t<></b> examples.</p>
|
<tr>
|
||||||
|
<th>Class Template</th>
|
||||||
|
<th>Template Parameter Mapping</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>boost::int_t</code></td>
|
||||||
|
<td>The smallest built-in signed integral type with at least the
|
||||||
|
given number of bits, including the sign bit. The parameter
|
||||||
|
should be a positive number. A compile-time error results if
|
||||||
|
the parameter is larger than the number of bits in a
|
||||||
|
<code>long</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>boost::uint_t</code></td>
|
||||||
|
<td>The smallest built-in unsigned integral type with at least
|
||||||
|
the given number of bits. The parameter should be a positive
|
||||||
|
number. A compile-time error results if the parameter is
|
||||||
|
larger than the number of bits in an <code>unsigned
|
||||||
|
long</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>boost::int_max_value_t</code></td>
|
||||||
|
<td>The smallest built-in signed integral type that supports the
|
||||||
|
given value as a maximum. The parameter should be a
|
||||||
|
positive number.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>boost::int_min_value_t</code></td>
|
||||||
|
<td>The smallest built-in signed integral type that supports the
|
||||||
|
given value as a minimum. The parameter should be a
|
||||||
|
negative number.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>boost::uint_value_t</code></td>
|
||||||
|
<td>The smallest built-in unsigned integral type that supports
|
||||||
|
the given value as a maximum. The parameter should be a
|
||||||
|
positive number.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<h2>Rationale</h2>
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
|
<blockquote><pre>#include <boost/integer.hpp>
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::int_t<24>::least my_var;
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
</pre></blockquote>
|
||||||
|
|
||||||
|
<h2><a name="demo">Demonstration Program</a></h2>
|
||||||
|
|
||||||
|
<p>The program <a href="integer_test.cpp">integer_test.cpp</a> is a
|
||||||
|
simplistic demonstration of the results from instantiating various
|
||||||
|
examples of the sized type class templates.</p>
|
||||||
|
|
||||||
|
<h2><a name="rationale">Rationale</a></h2>
|
||||||
|
|
||||||
<p>The rationale for the design of the templates in this header includes:</p>
|
<p>The rationale for the design of the templates in this header includes:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Avoid recursion because of concern about C++'s limited guaranteed
|
<li>Avoid recursion because of concern about C++'s limited
|
||||||
recursion depth (17).</li>
|
guaranteed recursion depth (17).</li>
|
||||||
<li>Avoid macros on general principles.</li>
|
<li>Avoid macros on general principles.</li>
|
||||||
<li>Try to keep the design as simple as possible.</li>
|
<li>Try to keep the design as simple as possible.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>Credits</h2>
|
<h2><a name="alternative">Alternative</a></h2>
|
||||||
|
|
||||||
<p>The author of the Boost integer type choosing templates is <a href="../../people/beman_dawes.html">Beman
|
<p>If the number of bits required is known beforehand, it may be more
|
||||||
Dawes</a>. He thanks to <a href="../../people/valentin_bonnard.htm"> Valentin Bonnard</a> and
|
appropriate to use the types supplied in <cite><a
|
||||||
<a href="../../people/kevlin_henney.htm"> Kevlin Henney</a> for sharing their designs for similar templates.</p>
|
href="../../boost/cstdint.hpp"><boost/cstdint.hpp></a></cite>.</p>
|
||||||
|
|
||||||
|
<h2><a name="credits">Credits</a></h2>
|
||||||
|
|
||||||
|
<p>The author of most of the Boost integer type choosing templates is <a
|
||||||
|
href="../../people/beman_dawes.html">Beman Dawes</a>. He gives thanks
|
||||||
|
to Valentin Bonnard and
|
||||||
|
<a href="../../people/kevlin_henney.htm"> Kevlin Henney</a> for sharing
|
||||||
|
their designs for similar templates. <a
|
||||||
|
href="../../people/daryle_walker.html">Daryle Walker</a> designed the
|
||||||
|
value-based sized templates.</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>Revised August 31, 1999</p>
|
<p>Revised May 20, 2001</p>
|
||||||
|
|
||||||
<p><EFBFBD> Copyright Beman Dawes 1999. Permission to copy, use, modify, sell
|
|
||||||
and distribute this document is granted provided this copyright notice appears in all
|
|
||||||
copies. This document is provided "as is" without express or implied warranty,
|
|
||||||
and with no claim as to its suitability for any purpose.</p>
|
|
||||||
|
|
||||||
<p></p>
|
|
||||||
|
|
||||||
<p> </p>
|
|
||||||
|
|
||||||
|
<p>© Copyright Beman Dawes 1999. Permission to copy, use, modify,
|
||||||
|
sell and distribute this document is granted provided this copyright
|
||||||
|
notice appears in all copies. This document is provided "as
|
||||||
|
is" without express or implied warranty, and with no claim as to
|
||||||
|
its suitability for any purpose.</p>
|
||||||
</body>
|
</body>
|
||||||
|
</html>
|
||||||
</html>
|
|
383
integer_test.cpp
383
integer_test.cpp
@ -9,168 +9,247 @@
|
|||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
// Revision History
|
// 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
|
// 31 Aug 99 Initial version
|
||||||
|
|
||||||
// This program is misnamed in that it is really a demonstration rather than
|
#define BOOST_INCLUDE_MAIN
|
||||||
// a test. It doesn't detect failure, so isn't worthy of the name "test".
|
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
|
||||||
|
|
||||||
#include <iostream>
|
#include <boost/config.hpp> // for BOOST_NO_USING_TEMPLATE
|
||||||
#include <boost/integer.hpp>
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
|
#include <boost/integer.hpp> // for boost::int_t, boost::uint_t
|
||||||
|
|
||||||
using namespace boost; // not the best practice, but useful for testing
|
#include <climits> // for ULONG_MAX, LONG_MAX, LONG_MIN
|
||||||
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
#include <typeinfo> // for std::type_info
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
void test( long ) { std::cout << "long\n"; }
|
|
||||||
void test( int ) { std::cout << "int\n"; }
|
|
||||||
void test( short ) { std::cout << "short\n"; }
|
|
||||||
void test( signed char ) { std::cout << "signed char\n"; }
|
|
||||||
void test( unsigned long ) { std::cout << "unsigned long\n"; }
|
|
||||||
void test( unsigned int ) { std::cout << "unsigned int\n"; }
|
|
||||||
void test( unsigned short ) { std::cout << "unsigned short\n"; }
|
|
||||||
void test( unsigned char ) { std::cout << "unsigned char\n"; }
|
|
||||||
} // unnamed namespace
|
|
||||||
|
|
||||||
// just to prove it works, specialize int_fast_t<short> to yield long
|
// 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
|
namespace boost
|
||||||
{
|
{
|
||||||
template<> struct int_fast_t<short> { typedef long fast; };
|
template < >
|
||||||
|
struct int_fast_t< short >
|
||||||
|
{
|
||||||
|
typedef long fast;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
|
||||||
|
// 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_TEST( 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; \
|
||||||
|
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 )
|
||||||
|
|
||||||
|
#define PRIVATE_SHIFTED_FIT_TEST(Template, Number, Type, Value) BOOST_TEST( 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_TEST( 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_TEST( 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*[]
|
||||||
|
)
|
||||||
{
|
{
|
||||||
std::cout << 32 << ' '; test( int_t<32>::least() );
|
#ifndef BOOST_NO_USING_TEMPLATE
|
||||||
std::cout << 31 << ' '; test( int_t<31>::least() );
|
using boost::int_t;
|
||||||
std::cout << 30 << ' '; test( int_t<30>::least() );
|
using boost::uint_t;
|
||||||
std::cout << 29 << ' '; test( int_t<29>::least() );
|
using boost::int_max_value_t;
|
||||||
std::cout << 28 << ' '; test( int_t<28>::least() );
|
using boost::int_min_value_t;
|
||||||
std::cout << 27 << ' '; test( int_t<27>::least() );
|
using boost::uint_value_t;
|
||||||
std::cout << 26 << ' '; test( int_t<26>::least() );
|
#else
|
||||||
std::cout << 25 << ' '; test( int_t<25>::least() );
|
using namespace boost;
|
||||||
std::cout << 24 << ' '; test( int_t<24>::least() );
|
#endif
|
||||||
std::cout << 23 << ' '; test( int_t<23>::least() );
|
|
||||||
std::cout << 22 << ' '; test( int_t<22>::least() );
|
|
||||||
std::cout << 21 << ' '; test( int_t<21>::least() );
|
|
||||||
std::cout << 20 << ' '; test( int_t<20>::least() );
|
|
||||||
std::cout << 19 << ' '; test( int_t<19>::least() );
|
|
||||||
std::cout << 18 << ' '; test( int_t<18>::least() );
|
|
||||||
std::cout << 17 << ' '; test( int_t<17>::least() );
|
|
||||||
std::cout << 16 << ' '; test( int_t<16>::least() );
|
|
||||||
std::cout << 15 << ' '; test( int_t<15>::least() );
|
|
||||||
std::cout << 14 << ' '; test( int_t<14>::least() );
|
|
||||||
std::cout << 13 << ' '; test( int_t<13>::least() );
|
|
||||||
std::cout << 12 << ' '; test( int_t<12>::least() );
|
|
||||||
std::cout << 11 << ' '; test( int_t<11>::least() );
|
|
||||||
std::cout << 10 << ' '; test( int_t<10>::least() );
|
|
||||||
std::cout << 9 << ' '; test( int_t<9>::least() );
|
|
||||||
std::cout << 8 << ' '; test( int_t<8>::least() );
|
|
||||||
std::cout << 7 << ' '; test( int_t<7>::least() );
|
|
||||||
std::cout << 6 << ' '; test( int_t<6>::least() );
|
|
||||||
std::cout << 5 << ' '; test( int_t<5>::least() );
|
|
||||||
std::cout << 4 << ' '; test( int_t<4>::least() );
|
|
||||||
std::cout << 3 << ' '; test( int_t<3>::least() );
|
|
||||||
std::cout << 2 << ' '; test( int_t<2>::least() );
|
|
||||||
std::cout << 1 << ' '; test( int_t<1>::least() );
|
|
||||||
std::cout << 0 << ' '; test( int_t<0>::least() );
|
|
||||||
std::cout << 32 << ' '; test( int_t<32>::fast() );
|
|
||||||
std::cout << 31 << ' '; test( int_t<31>::fast() );
|
|
||||||
std::cout << 30 << ' '; test( int_t<30>::fast() );
|
|
||||||
std::cout << 29 << ' '; test( int_t<29>::fast() );
|
|
||||||
std::cout << 28 << ' '; test( int_t<28>::fast() );
|
|
||||||
std::cout << 27 << ' '; test( int_t<27>::fast() );
|
|
||||||
std::cout << 26 << ' '; test( int_t<26>::fast() );
|
|
||||||
std::cout << 25 << ' '; test( int_t<25>::fast() );
|
|
||||||
std::cout << 24 << ' '; test( int_t<24>::fast() );
|
|
||||||
std::cout << 23 << ' '; test( int_t<23>::fast() );
|
|
||||||
std::cout << 22 << ' '; test( int_t<22>::fast() );
|
|
||||||
std::cout << 21 << ' '; test( int_t<21>::fast() );
|
|
||||||
std::cout << 20 << ' '; test( int_t<20>::fast() );
|
|
||||||
std::cout << 19 << ' '; test( int_t<19>::fast() );
|
|
||||||
std::cout << 18 << ' '; test( int_t<18>::fast() );
|
|
||||||
std::cout << 17 << ' '; test( int_t<17>::fast() );
|
|
||||||
std::cout << 16 << ' '; test( int_t<16>::fast() );
|
|
||||||
std::cout << 15 << ' '; test( int_t<15>::fast() );
|
|
||||||
std::cout << 14 << ' '; test( int_t<14>::fast() );
|
|
||||||
std::cout << 13 << ' '; test( int_t<13>::fast() );
|
|
||||||
std::cout << 12 << ' '; test( int_t<12>::fast() );
|
|
||||||
std::cout << 11 << ' '; test( int_t<11>::fast() );
|
|
||||||
std::cout << 10 << ' '; test( int_t<10>::fast() );
|
|
||||||
std::cout << 9 << ' '; test( int_t<9>::fast() );
|
|
||||||
std::cout << 8 << ' '; test( int_t<8>::fast() );
|
|
||||||
std::cout << 7 << ' '; test( int_t<7>::fast() );
|
|
||||||
std::cout << 6 << ' '; test( int_t<6>::fast() );
|
|
||||||
std::cout << 5 << ' '; test( int_t<5>::fast() );
|
|
||||||
std::cout << 4 << ' '; test( int_t<4>::fast() );
|
|
||||||
std::cout << 3 << ' '; test( int_t<3>::fast() );
|
|
||||||
std::cout << 2 << ' '; test( int_t<2>::fast() );
|
|
||||||
std::cout << 1 << ' '; test( int_t<1>::fast() );
|
|
||||||
std::cout << 0 << ' '; test( int_t<0>::fast() );
|
|
||||||
std::cout << 32 << ' '; test( uint_t<32>::least() );
|
|
||||||
std::cout << 31 << ' '; test( uint_t<31>::least() );
|
|
||||||
std::cout << 30 << ' '; test( uint_t<30>::least() );
|
|
||||||
std::cout << 29 << ' '; test( uint_t<29>::least() );
|
|
||||||
std::cout << 28 << ' '; test( uint_t<28>::least() );
|
|
||||||
std::cout << 27 << ' '; test( uint_t<27>::least() );
|
|
||||||
std::cout << 26 << ' '; test( uint_t<26>::least() );
|
|
||||||
std::cout << 25 << ' '; test( uint_t<25>::least() );
|
|
||||||
std::cout << 24 << ' '; test( uint_t<24>::least() );
|
|
||||||
std::cout << 23 << ' '; test( uint_t<23>::least() );
|
|
||||||
std::cout << 22 << ' '; test( uint_t<22>::least() );
|
|
||||||
std::cout << 21 << ' '; test( uint_t<21>::least() );
|
|
||||||
std::cout << 20 << ' '; test( uint_t<20>::least() );
|
|
||||||
std::cout << 19 << ' '; test( uint_t<19>::least() );
|
|
||||||
std::cout << 18 << ' '; test( uint_t<18>::least() );
|
|
||||||
std::cout << 17 << ' '; test( uint_t<17>::least() );
|
|
||||||
std::cout << 16 << ' '; test( uint_t<16>::least() );
|
|
||||||
std::cout << 15 << ' '; test( uint_t<15>::least() );
|
|
||||||
std::cout << 14 << ' '; test( uint_t<14>::least() );
|
|
||||||
std::cout << 13 << ' '; test( uint_t<13>::least() );
|
|
||||||
std::cout << 12 << ' '; test( uint_t<12>::least() );
|
|
||||||
std::cout << 11 << ' '; test( uint_t<11>::least() );
|
|
||||||
std::cout << 10 << ' '; test( uint_t<10>::least() );
|
|
||||||
std::cout << 9 << ' '; test( uint_t<9>::least() );
|
|
||||||
std::cout << 8 << ' '; test( uint_t<8>::least() );
|
|
||||||
std::cout << 7 << ' '; test( uint_t<7>::least() );
|
|
||||||
std::cout << 6 << ' '; test( uint_t<6>::least() );
|
|
||||||
std::cout << 5 << ' '; test( uint_t<5>::least() );
|
|
||||||
std::cout << 4 << ' '; test( uint_t<4>::least() );
|
|
||||||
std::cout << 3 << ' '; test( uint_t<3>::least() );
|
|
||||||
std::cout << 2 << ' '; test( uint_t<2>::least() );
|
|
||||||
std::cout << 1 << ' '; test( uint_t<1>::least() );
|
|
||||||
std::cout << 0 << ' '; test( uint_t<0>::least() );
|
|
||||||
std::cout << 32 << ' '; test( uint_t<32>::fast() );
|
|
||||||
std::cout << 31 << ' '; test( uint_t<31>::fast() );
|
|
||||||
std::cout << 30 << ' '; test( uint_t<30>::fast() );
|
|
||||||
std::cout << 29 << ' '; test( uint_t<29>::fast() );
|
|
||||||
std::cout << 28 << ' '; test( uint_t<28>::fast() );
|
|
||||||
std::cout << 27 << ' '; test( uint_t<27>::fast() );
|
|
||||||
std::cout << 26 << ' '; test( uint_t<26>::fast() );
|
|
||||||
std::cout << 25 << ' '; test( uint_t<25>::fast() );
|
|
||||||
std::cout << 24 << ' '; test( uint_t<24>::fast() );
|
|
||||||
std::cout << 23 << ' '; test( uint_t<23>::fast() );
|
|
||||||
std::cout << 22 << ' '; test( uint_t<22>::fast() );
|
|
||||||
std::cout << 21 << ' '; test( uint_t<21>::fast() );
|
|
||||||
std::cout << 20 << ' '; test( uint_t<20>::fast() );
|
|
||||||
std::cout << 19 << ' '; test( uint_t<19>::fast() );
|
|
||||||
std::cout << 18 << ' '; test( uint_t<18>::fast() );
|
|
||||||
std::cout << 17 << ' '; test( uint_t<17>::fast() );
|
|
||||||
std::cout << 16 << ' '; test( uint_t<16>::fast() );
|
|
||||||
std::cout << 15 << ' '; test( uint_t<15>::fast() );
|
|
||||||
std::cout << 14 << ' '; test( uint_t<14>::fast() );
|
|
||||||
std::cout << 13 << ' '; test( uint_t<13>::fast() );
|
|
||||||
std::cout << 12 << ' '; test( uint_t<12>::fast() );
|
|
||||||
std::cout << 11 << ' '; test( uint_t<11>::fast() );
|
|
||||||
std::cout << 10 << ' '; test( uint_t<10>::fast() );
|
|
||||||
std::cout << 9 << ' '; test( uint_t<9>::fast() );
|
|
||||||
std::cout << 8 << ' '; test( uint_t<8>::fast() );
|
|
||||||
std::cout << 7 << ' '; test( uint_t<7>::fast() );
|
|
||||||
std::cout << 6 << ' '; test( uint_t<6>::fast() );
|
|
||||||
std::cout << 5 << ' '; test( uint_t<5>::fast() );
|
|
||||||
std::cout << 4 << ' '; test( uint_t<4>::fast() );
|
|
||||||
std::cout << 3 << ' '; test( uint_t<3>::fast() );
|
|
||||||
std::cout << 2 << ' '; test( uint_t<2>::fast() );
|
|
||||||
std::cout << 1 << ' '; test( uint_t<1>::fast() );
|
|
||||||
std::cout << 0 << ' '; test( uint_t<0>::fast() );
|
|
||||||
|
|
||||||
return 0;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright Jens Maurer 2000
|
* Copyright Jens Maurer 2000
|
||||||
* Permission to use, copy, modify, sell, and distribute this software
|
* Permission to use, copy, modify, sell, and distribute this software
|
||||||
* is hereby granted without free provided that the above copyright notice
|
* is hereby granted without fee provided that the above copyright notice
|
||||||
* appears in all copies and that both that copyright notice and this
|
* appears in all copies and that both that copyright notice and this
|
||||||
* permission notice appear in supporting documentation,
|
* permission notice appear in supporting documentation,
|
||||||
*
|
*
|
||||||
@ -18,15 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cassert>
|
|
||||||
#include <boost/integer_traits.hpp>
|
#include <boost/integer_traits.hpp>
|
||||||
// use int64_t instead of long long for better portability
|
// use int64_t instead of long long for better portability
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#define BOOST_INCLUDE_MAIN
|
||||||
#error This test relies on assert() and thus makes no sense with NDEBUG defined
|
#include <boost/test/test_tools.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* General portability note:
|
* General portability note:
|
||||||
@ -38,22 +35,37 @@
|
|||||||
* Therefore, avoid 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>
|
template<class T>
|
||||||
void runtest(const char * type, T)
|
void runtest(const char * type, T)
|
||||||
{
|
{
|
||||||
typedef boost::integer_traits<T> traits;
|
typedef boost::integer_traits<T> traits;
|
||||||
std::cout << "Checking " << type
|
std::cout << "Checking " << type
|
||||||
<< "; min is " << traits::min()
|
<< "; min is " << make_char_numeric_for_streaming(traits::min())
|
||||||
<< ", max is " << traits::max()
|
<< ", max is " << make_char_numeric_for_streaming(traits::max())
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
assert(traits::is_specialized);
|
BOOST_TEST(traits::is_specialized);
|
||||||
assert(traits::is_integer);
|
BOOST_TEST(traits::is_integer);
|
||||||
assert(traits::is_integral);
|
BOOST_TEST(traits::is_integral);
|
||||||
assert(traits::const_min == traits::min());
|
BOOST_TEST(traits::const_min == traits::min());
|
||||||
assert(traits::const_max == traits::max());
|
BOOST_TEST(traits::const_max == traits::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int test_main(int, char*[])
|
||||||
{
|
{
|
||||||
runtest("bool", bool());
|
runtest("bool", bool());
|
||||||
runtest("char", char());
|
runtest("char", char());
|
||||||
@ -61,6 +73,7 @@ int main()
|
|||||||
runtest("signed char", signed_char());
|
runtest("signed char", signed_char());
|
||||||
typedef unsigned char unsigned_char;
|
typedef unsigned char unsigned_char;
|
||||||
runtest("unsigned char", unsigned_char());
|
runtest("unsigned char", unsigned_char());
|
||||||
|
runtest("wchar_t", wchar_t());
|
||||||
runtest("short", short());
|
runtest("short", short());
|
||||||
typedef unsigned short unsigned_short;
|
typedef unsigned short unsigned_short;
|
||||||
runtest("unsigned short", unsigned_short());
|
runtest("unsigned short", unsigned_short());
|
||||||
@ -70,13 +83,17 @@ int main()
|
|||||||
runtest("long", long());
|
runtest("long", long());
|
||||||
typedef unsigned long unsigned_long;
|
typedef unsigned long unsigned_long;
|
||||||
runtest("unsigned long", unsigned_long());
|
runtest("unsigned long", unsigned_long());
|
||||||
#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
|
#if !defined(BOOST_NO_INT64_T) && (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && !defined(__BORLANDC__) && !defined(__BEOS__)
|
||||||
//
|
//
|
||||||
// MS/Borland compilers can't support 64-bit member constants
|
// 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("int64_t (possibly long long)", boost::int64_t());
|
||||||
runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
|
runtest("uint64_t (possibly unsigned long long)", boost::uint64_t());
|
||||||
|
#else
|
||||||
|
std::cout << "Skipped int64_t and uint64_t" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// Some compilers don't pay attention to std:3.6.1/5 and issue a
|
// Some compilers don't pay attention to std:3.6.1/5 and issue a
|
||||||
// warning here if "return 0;" is omitted.
|
// warning here if "return 0;" is omitted.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
112
test/integer_mask_test.cpp
Normal file
112
test/integer_mask_test.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
// Revision History
|
||||||
|
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||||
|
|
||||||
|
#define BOOST_INCLUDE_MAIN
|
||||||
|
#include <boost/test/test_tools.hpp> // for main
|
||||||
|
|
||||||
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
|
#include <boost/integer/integer_mask.hpp> // for boost::high_bit_mask_t, etc.
|
||||||
|
|
||||||
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
|
||||||
|
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||||
|
(v) >::high_bit == (1ul << (v)) );
|
||||||
|
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||||
|
(v) >::high_bit_fast == (1ul << (v)) );
|
||||||
|
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
|
||||||
|
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
|
#define PRIVATE_LOW_BITS_SLOW_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
||||||
|
(v) >::sig_bits == ((1ul << (v)) - 1) );
|
||||||
|
#define PRIVATE_LOW_BITS_FAST_TEST(v) BOOST_TEST( ::boost::low_bits_mask_t< \
|
||||||
|
(v) >::sig_bits_fast == ((1ul << (v)) - 1) );
|
||||||
|
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
|
||||||
|
PRIVATE_LOW_BITS_FAST_TEST(v); } while (false)
|
||||||
|
|
||||||
|
|
||||||
|
int test_main( int, char*[] )
|
||||||
|
{
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
cout << "Doing high_bit_mask_t tests." << endl;
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 31 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 30 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 29 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 28 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 27 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 26 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 25 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 24 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 23 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 22 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 21 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 20 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 19 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 18 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 17 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 16 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 15 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 14 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 13 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 12 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 11 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 10 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 9 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 8 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 7 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 6 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 5 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 4 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 3 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 2 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 1 );
|
||||||
|
PRIVATE_HIGH_BIT_TEST( 0 );
|
||||||
|
|
||||||
|
cout << "Doing low_bits_mask_t tests." << endl;
|
||||||
|
PRIVATE_LOW_BITS_TEST( 32 ); // Undefined behavior? Whoops!
|
||||||
|
PRIVATE_LOW_BITS_TEST( 31 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 30 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 29 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 28 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 27 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 26 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 25 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 24 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 23 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 22 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 21 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 20 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 19 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 18 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 17 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 16 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 15 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 14 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 13 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 12 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 11 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 10 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 9 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 8 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 7 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 6 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 5 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 4 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 3 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 2 );
|
||||||
|
PRIVATE_LOW_BITS_TEST( 1 );
|
||||||
|
|
||||||
|
return boost::exit_success;
|
||||||
|
}
|
151
test/static_log2_test.cpp
Normal file
151
test/static_log2_test.cpp
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
// Revision History
|
||||||
|
// 01 Oct 2001 Initial version (Daryle Walker)
|
||||||
|
|
||||||
|
#define BOOST_INCLUDE_MAIN
|
||||||
|
#include <boost/test/test_tools.hpp> // for main
|
||||||
|
|
||||||
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
|
#include <boost/integer/static_log2.hpp> // for boost::static_log2
|
||||||
|
|
||||||
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
|
||||||
|
// Macros to compact code
|
||||||
|
#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) \
|
||||||
|
<< "> = " << ::boost::static_log2< (v) >::value << '.' << ::std::endl
|
||||||
|
|
||||||
|
// Control to check for a compile-time error
|
||||||
|
#ifndef CONTROL_LB_0_TEST
|
||||||
|
#define PRIVATE_LB_0_TEST
|
||||||
|
#else
|
||||||
|
#define PRIVATE_LB_0_TEST PRIVATE_PRINT_LB( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Main testing function
|
||||||
|
int
|
||||||
|
test_main
|
||||||
|
(
|
||||||
|
int , // "argc" is unused
|
||||||
|
char * [] // "argv" is unused
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::cout << "Doing tests on static_log2." << std::endl;
|
||||||
|
|
||||||
|
PRIVATE_LB_0_TEST;
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 1, 0 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 2, 1 );
|
||||||
|
PRIVATE_LB_TEST( 3, 1 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 4, 2 );
|
||||||
|
PRIVATE_LB_TEST( 5, 2 );
|
||||||
|
PRIVATE_LB_TEST( 6, 2 );
|
||||||
|
PRIVATE_LB_TEST( 7, 2 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 8, 3 );
|
||||||
|
PRIVATE_LB_TEST( 9, 3 );
|
||||||
|
PRIVATE_LB_TEST( 10, 3 );
|
||||||
|
PRIVATE_LB_TEST( 11, 3 );
|
||||||
|
PRIVATE_LB_TEST( 12, 3 );
|
||||||
|
PRIVATE_LB_TEST( 13, 3 );
|
||||||
|
PRIVATE_LB_TEST( 14, 3 );
|
||||||
|
PRIVATE_LB_TEST( 15, 3 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 16, 4 );
|
||||||
|
PRIVATE_LB_TEST( 17, 4 );
|
||||||
|
PRIVATE_LB_TEST( 18, 4 );
|
||||||
|
PRIVATE_LB_TEST( 19, 4 );
|
||||||
|
PRIVATE_LB_TEST( 20, 4 );
|
||||||
|
PRIVATE_LB_TEST( 21, 4 );
|
||||||
|
PRIVATE_LB_TEST( 22, 4 );
|
||||||
|
PRIVATE_LB_TEST( 23, 4 );
|
||||||
|
PRIVATE_LB_TEST( 24, 4 );
|
||||||
|
PRIVATE_LB_TEST( 25, 4 );
|
||||||
|
PRIVATE_LB_TEST( 26, 4 );
|
||||||
|
PRIVATE_LB_TEST( 27, 4 );
|
||||||
|
PRIVATE_LB_TEST( 28, 4 );
|
||||||
|
PRIVATE_LB_TEST( 29, 4 );
|
||||||
|
PRIVATE_LB_TEST( 30, 4 );
|
||||||
|
PRIVATE_LB_TEST( 31, 4 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 32, 5 );
|
||||||
|
PRIVATE_LB_TEST( 33, 5 );
|
||||||
|
PRIVATE_LB_TEST( 34, 5 );
|
||||||
|
PRIVATE_LB_TEST( 35, 5 );
|
||||||
|
PRIVATE_LB_TEST( 36, 5 );
|
||||||
|
PRIVATE_LB_TEST( 37, 5 );
|
||||||
|
PRIVATE_LB_TEST( 38, 5 );
|
||||||
|
PRIVATE_LB_TEST( 39, 5 );
|
||||||
|
PRIVATE_LB_TEST( 40, 5 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 63, 5 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 64, 6 );
|
||||||
|
PRIVATE_LB_TEST( 65, 6 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 127, 6 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 128, 7 );
|
||||||
|
PRIVATE_LB_TEST( 129, 7 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 255, 7 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 256, 8 );
|
||||||
|
PRIVATE_LB_TEST( 257, 8 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 511, 8 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 512, 9 );
|
||||||
|
PRIVATE_LB_TEST( 513, 9 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 1023, 9 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 1024, 10 );
|
||||||
|
PRIVATE_LB_TEST( 1025, 10 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 2047, 10 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 2048, 11 );
|
||||||
|
PRIVATE_LB_TEST( 2049, 11 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 4095, 11 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 4096, 12 );
|
||||||
|
PRIVATE_LB_TEST( 4097, 12 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 8191, 12 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 8192, 13 );
|
||||||
|
PRIVATE_LB_TEST( 8193, 13 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 16383, 13 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 16384, 14 );
|
||||||
|
PRIVATE_LB_TEST( 16385, 14 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 32767, 14 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 32768, 15 );
|
||||||
|
PRIVATE_LB_TEST( 32769, 15 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 65535, 15 );
|
||||||
|
|
||||||
|
PRIVATE_LB_TEST( 65536, 16 );
|
||||||
|
PRIVATE_LB_TEST( 65537, 16 );
|
||||||
|
|
||||||
|
return boost::exit_success;
|
||||||
|
}
|
94
test/static_min_max_test.cpp
Normal file
94
test/static_min_max_test.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
|
// Revision History
|
||||||
|
// 23 Sep 2001 Initial version (Daryle Walker)
|
||||||
|
|
||||||
|
#define BOOST_INCLUDE_MAIN
|
||||||
|
#include <boost/test/test_tools.hpp> // for main, BOOST_TEST
|
||||||
|
|
||||||
|
#include <boost/cstdlib.hpp> // for boost::exit_success
|
||||||
|
#include <boost/integer/static_min_max.hpp> // for boost::static_signed_min, etc.
|
||||||
|
|
||||||
|
#include <iostream> // for std::cout (std::endl indirectly)
|
||||||
|
|
||||||
|
|
||||||
|
// Main testing function
|
||||||
|
int
|
||||||
|
test_main
|
||||||
|
(
|
||||||
|
int , // "argc" is unused
|
||||||
|
char * [] // "argv" is unused
|
||||||
|
)
|
||||||
|
{
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
using boost::static_signed_min;
|
||||||
|
using boost::static_signed_max;
|
||||||
|
using boost::static_unsigned_min;
|
||||||
|
using boost::static_unsigned_max;
|
||||||
|
|
||||||
|
// Two positives
|
||||||
|
cout << "Doing tests with two positive values." << endl;
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min< 9, 14>::value) == 9 );
|
||||||
|
BOOST_TEST( (static_signed_max< 9, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_signed_min<14, 9>::value) == 9 );
|
||||||
|
BOOST_TEST( (static_signed_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
|
BOOST_TEST( (static_unsigned_min< 9, 14>::value) == 9 );
|
||||||
|
BOOST_TEST( (static_unsigned_max< 9, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_unsigned_min<14, 9>::value) == 9 );
|
||||||
|
BOOST_TEST( (static_unsigned_max<14, 9>::value) == 14 );
|
||||||
|
|
||||||
|
// Two negatives
|
||||||
|
cout << "Doing tests with two negative values." << endl;
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min< -8, -101>::value) == -101 );
|
||||||
|
BOOST_TEST( (static_signed_max< -8, -101>::value) == -8 );
|
||||||
|
BOOST_TEST( (static_signed_min<-101, -8>::value) == -101 );
|
||||||
|
BOOST_TEST( (static_signed_max<-101, -8>::value) == -8 );
|
||||||
|
|
||||||
|
// With zero
|
||||||
|
cout << "Doing tests with zero and a positive or negative value." << endl;
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min< 0, 14>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_signed_max< 0, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_signed_min<14, 0>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_signed_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
|
BOOST_TEST( (static_unsigned_min< 0, 14>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_unsigned_max< 0, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_unsigned_min<14, 0>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_unsigned_max<14, 0>::value) == 14 );
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min< 0, -101>::value) == -101 );
|
||||||
|
BOOST_TEST( (static_signed_max< 0, -101>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_signed_min<-101, 0>::value) == -101 );
|
||||||
|
BOOST_TEST( (static_signed_max<-101, 0>::value) == 0 );
|
||||||
|
|
||||||
|
// With identical
|
||||||
|
cout << "Doing tests with two identical values." << endl;
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min<0, 0>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_signed_max<0, 0>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_unsigned_min<0, 0>::value) == 0 );
|
||||||
|
BOOST_TEST( (static_unsigned_max<0, 0>::value) == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min<14, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_signed_max<14, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_unsigned_min<14, 14>::value) == 14 );
|
||||||
|
BOOST_TEST( (static_unsigned_max<14, 14>::value) == 14 );
|
||||||
|
|
||||||
|
BOOST_TEST( (static_signed_min< -101, -101>::value) == -101 );
|
||||||
|
BOOST_TEST( (static_signed_max< -101, -101>::value) == -101 );
|
||||||
|
|
||||||
|
return boost::exit_success;
|
||||||
|
}
|
Reference in New Issue
Block a user