Fix issues in docs.

[SVN r58008]
This commit is contained in:
John Maddock
2009-11-28 17:08:31 +00:00
parent 6a497ee263
commit 05c1f88324
9 changed files with 288 additions and 209 deletions

View File

@ -49,10 +49,11 @@
integer widths. All typedef's are in namespace boost.
</p>
<p>
The specifications are based on the ISO/IEC 9899:1999 C Language standard
header &lt;stdint.h&gt;. The 64-bit types required by the C standard are
not required in the boost header, and may not be supplied in all implementations,
because <code class="literal">long long</code> is not [yet] included in the C++ standard.
The specifications for these types are based on the ISO/IEC 9899:1999 C Language
standard header &lt;stdint.h&gt;. The 64-bit types required by the C standard
are <span class="emphasis"><em>not required</em></span> in the boost header, and may not be
supplied for all platforms/compilers, because <code class="literal">long long</code>
is not [yet] included in the C++ standard.
</p>
<p>
See <a href="../../../test/cstdint_test.cpp" target="_top">cstdint_test.cpp</a> for
@ -66,13 +67,13 @@
<p>
The organization of the Boost.Integer headers and classes is designed to
take advantage of &lt;stdint.h&gt; types from the 1999 C standard without
resorting to undefined behavior in terms of the 1998 C++ standard. The header
causing undefined behavior in terms of the 1998 C++ standard. The header
&lt;boost/cstdint.hpp&gt; makes the standard integer types safely available
in namespace <code class="literal">boost</code> without placing any names in namespace
<code class="literal">std</code>. As always, the intension is to complement rather
than compete with the C++ Standard Library. Should some future C++ standard
include &lt;stdint.h&gt; and &lt;cstdint&gt;, then &lt;boost/cstdint.hpp&gt;
will continue to function, but will become redundant and may be safely deprecated.
<code class="literal">std</code>. The intension is to complement rather than compete
with the C++ Standard Library. Should some future C++ standard include &lt;stdint.h&gt;
and &lt;cstdint&gt;, then &lt;boost/cstdint.hpp&gt; 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
@ -108,9 +109,9 @@
designates an unsigned integer type of exactly # bits.
</p>
<p>
These types are optional. However, if an implementation provides integer
types with widths of 8, 16, 32, or 64 bits, it shall define the corresponding
typedef names.
These types are optional. However, if a platform supports integer types with
widths of 8, 16, 32, 64, or any combination thereof, then &lt;boost/cstdint.hpp&gt;
does provide the corresponding typedefs.
</p>
<p>
The absence of int64_t and uint64_t is indicated by the macro <code class="computeroutput"><span class="identifier">BOOST_NO_INT64_T</span></code>.
@ -125,14 +126,14 @@
The typedef <code class="literal">int_least#_t</code>, with # replaced by the width,
designates a signed integer type with a width of at least # bits, such that
no signed integer type with lesser size has at least the specified width.
Thus, <code class="literal">int_least32_t</code> denotes a signed integer type with
a width of at least 32 bits. Similarly, the typedef name <code class="literal">uint_least#_t</code>
Thus, <code class="literal">int_least32_t</code> denotes the smallest signed integer
type with a width of at least 32 bits. Similarly, the typedef name <code class="literal">uint_least#_t</code>
designates an unsigned integer type with a width of at least # bits, such
that no unsigned integer type with lesser size has at least the specified
width.
</p>
<p>
Required minimum-width integer types:
The following minimum-width integer types are provided for all platforms:
</p>
<div class="itemizedlist"><ul type="disc">
<li><code class="literal">int_least8_t</code></li>
@ -143,17 +144,13 @@
<li><code class="literal">uint_least32_t</code></li>
</ul></div>
<p>
The types:
The following types are available only if, after including &lt;boost/cstdint.hpp&gt;,
the macro BOOST_NO_INT64_T is not defined:
</p>
<div class="itemizedlist"><ul type="disc">
<li><code class="literal">int_least64_t</code></li>
<li><code class="literal">uint_least64_t</code></li>
</ul></div>
<p>
Are available only if, after inclusion of <code class="literal">&lt;boost/cstdint.hpp&gt;</code>
the macro <code class="computeroutput"><span class="identifier">BOOST_NO_INT64_T</span></code>
is <span class="emphasis"><em><span class="bold"><strong>not defined</strong></span></em></span>.
</p>
<p>
All other minimum-width integer types are optional.
</p>
@ -174,7 +171,7 @@
case, however, they satisfy the signedness and width requirements.
</p>
<p>
Required fastest minimum-width integer types:
The following fastest minimum-width integer types are provided for all platforms:
</p>
<div class="itemizedlist"><ul type="disc">
<li><code class="literal">int_fast8_t</code></li>
@ -185,17 +182,13 @@
<li><code class="literal">uint_fast32_t</code></li>
</ul></div>
<p>
The types:
The following types are available only if, after including &lt;boost/cstdint.hpp&gt;,
the macro BOOST_NO_INT64_T is not defined:
</p>
<div class="itemizedlist"><ul type="disc">
<li><code class="literal">int_fast64_t</code></li>
<li><code class="literal">uint_fast64_t</code></li>
</ul></div>
<p>
Are available only if, after inclusion of <code class="literal">&lt;boost/cstdint.hpp&gt;</code>
the macro <code class="computeroutput"><span class="identifier">BOOST_NO_INT64_T</span></code>
is <span class="emphasis"><em><span class="bold"><strong>not defined</strong></span></em></span>.
</p>
<p>
All other fastest minimum-width integer types are optional.
</p>
@ -214,7 +207,7 @@
capable of representing any value of any unsigned integer type.
</p>
<p>
These types are required.
These types are provided for all platforms.
</p>
</div>
</div>

View File

@ -26,7 +26,7 @@
<a name="boost_integer.history"></a><a class="link" href="history.html" title="History"> History</a>
</h2></div></div></div>
<a name="boost_integer.history.1_42_0"></a><h5>
<a name="id773547"></a>
<a name="id768488"></a>
<a class="link" href="history.html#boost_integer.history.1_42_0">1.42.0</a>
</h5>
<div class="itemizedlist"><ul type="disc">
@ -55,7 +55,7 @@
</li>
</ul></div>
<a name="boost_integer.history.1_32_0"></a><h5>
<a name="id773649"></a>
<a name="id768590"></a>
<a class="link" href="history.html#boost_integer.history.1_32_0">1.32.0</a>
</h5>
<div class="itemizedlist"><ul type="disc"><li>

View File

@ -54,7 +54,7 @@
</span> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">LeastInt</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_fast_t</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">fast</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="emphasis"><em>implementation-defined-type</em></span> <span class="identifier">type</span><span class="special">;</span>
<span class="special">};</span>
<span class="comment">// signed
@ -115,13 +115,12 @@
to <code class="literal">int</code> objects before processing. The input type, passed
as the only template parameter, must be a built-in integral type, except
<code class="literal">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 class="literal">fast</code>.
signed integral types. The output type is given as the nested type <code class="literal">fast</code>.
</p>
<p>
<span class="bold"><strong>Implementation Notes:</strong></span> By default, the output
type is identical to the input type. Eventually, this code's implementation
should be conditionalized for each platform to give accurate mappings between
should be customized 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.
@ -135,12 +134,12 @@
The <code class="literal">int_t</code>, <code class="literal">uint_t</code>, <code class="literal">int_max_value_t</code>,
<code class="literal">int_min_value_t</code>, and <code class="literal">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 class="literal">least</code>.
The easiest-to-manipulate version of that type is given by the class member
parameter. This type is given by the nested type <code class="literal">least</code>.
The easiest-to-manipulate version of that type is given by the nested type
<code class="literal">fast</code>. The following table describes each template's criteria.
</p>
<div class="table">
<a name="id768468"></a><p class="title"><b>Table&#160;1.&#160;Criteria for the Sized Type Class Templates</b></p>
<a name="id764075"></a><p class="title"><b>Table&#160;1.&#160;Criteria for the Sized Type Class Templates</b></p>
<div class="table-contents"><table class="table" summary="Criteria for the Sized Type Class Templates">
<colgroup>
<col>
@ -162,33 +161,91 @@
<tr>
<td>
<p>
<code class="literal">boost::int_t&lt;N&gt;</code>
<code class="literal">boost::int_t&lt;N&gt;::least</code>
</p>
</td>
<td>
<p>
The smallest built-in signed integral type with at least <span class="emphasis"><em>N</em></span>
The smallest, built-in, signed integral type with at least <span class="emphasis"><em>N</em></span>
bits, including the sign bit. The parameter should be a positive number.
A compile-time error results if the parameter is larger than the number
of bits in the largest integer type. Note that the member <span class="emphasis"><em>exact</em></span>
is defined <span class="bold"><strong>only</strong></span> if there is a type
with exactly N bits.
of bits in the largest integer type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_t&lt;N&gt;</code>
<code class="literal">boost::int_t&lt;N&gt;::fast</code>
</p>
</td>
<td>
<p>
The smallest built-in unsigned integral type with at least <span class="emphasis"><em>N</em></span>
The easiest-to-manipulate, built-in, signed integral type with at least
<span class="emphasis"><em>N</em></span> bits, including the sign bit. The parameter
should be a positive number. A compile-time error results if the parameter
is larger than the number of bits in the largest integer type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::int_t&lt;N&gt;::exact</code>
</p>
</td>
<td>
<p>
A built-in, signed integral type with exactly <span class="emphasis"><em>N</em></span>
bits, including the sign bit. The parameter should be a positive number.
Note that the member <span class="emphasis"><em>exact</em></span> is defined <span class="bold"><strong>only</strong></span> if there exists a type with exactly <span class="emphasis"><em>N</em></span>
bits.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_t&lt;N&gt;::least</code>
</p>
</td>
<td>
<p>
The smallest, built-in, unsigned integral type with at least <span class="emphasis"><em>N</em></span>
bits. The parameter should be a positive number. A compile-time error
results if the parameter is larger than the number of bits in the largest
integer type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_t&lt;N&gt;::fast</code>
</p>
</td>
<td>
<p>
The easiest-to-manipulate, built-in, unsigned integral type with at
least <span class="emphasis"><em>N</em></span> bits. The parameter should be a positive
number. A compile-time error results if the parameter is larger than
the number of bits in the largest integer type.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_t&lt;N&gt;::exact</code>
</p>
</td>
<td>
<p>
A built-in, unsigned integral type with exactly <span class="emphasis"><em>N</em></span>
bits. The parameter should be a positive number. A compile-time error
results if the parameter is larger than the number of bits in the largest
integer type. Note that the member <span class="emphasis"><em>exact</em></span> is defined
<span class="bold"><strong>only</strong></span> if there is a type with exactly
<span class="bold"><strong>only</strong></span> if there exists a type with exactly
N bits.
</p>
</td>
@ -196,45 +253,87 @@
<tr>
<td>
<p>
<code class="literal">boost::int_max_value_t&lt;V&gt;</code>
<code class="literal">boost::int_max_value_t&lt;V&gt;::last</code>
</p>
</td>
<td>
<p>
The smallest built-in signed integral type that can hold all the values
in the inclusive range <span class="emphasis"><em>0 - V</em></span>. The parameter should
be a positive number.
The smallest, built-in, signed integral type that can hold all the
values in the inclusive range <span class="emphasis"><em>0 - V</em></span>. The parameter
should be a positive number.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::int_min_value_t&lt;V&gt;</code>
<code class="literal">boost::int_max_value_t&lt;V&gt;::fast</code>
</p>
</td>
<td>
<p>
The smallest built-in signed integral type that can hold all the values
in the inclusive range <span class="emphasis"><em>V-0</em></span>. The parameter should
be a negative number.
The easiest-to-manipulate, built-in, signed integral type that can
hold all the values in the inclusive range <span class="emphasis"><em>0 - V</em></span>.
The parameter should be a positive number.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_value_t&lt;V&gt;</code>
<code class="literal">boost::int_min_value_t&lt;V&gt;::least</code>
</p>
</td>
<td>
<p>
The smallest built-in unsigned integral type that can hold all positive
The smallest, built-in, signed integral type that can hold all the
values in the inclusive range <span class="emphasis"><em>V - 0</em></span>. The parameter
should be a negative number.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::int_min_value_t&lt;V&gt;::fast</code>
</p>
</td>
<td>
<p>
The easiest-to-manipulate, built-in, signed integral type that can
hold all the values in the inclusive range <span class="emphasis"><em>V - 0</em></span>.
The parameter should be a negative number.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_value_t&lt;V&gt;::least</code>
</p>
</td>
<td>
<p>
The smallest, built-in, unsigned integral type that can hold all positive
values up to and including <span class="emphasis"><em>V</em></span>. The parameter should
be a positive number.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="literal">boost::uint_value_t&lt;V&gt;::fast</code>
</p>
</td>
<td>
<p>
The easiest-to-manipulate, built-in, unsigned integral type that can
hold all positive values up to and including <span class="emphasis"><em>V</em></span>.
The parameter should be a positive number.
</p>
</td>
</tr>
</tbody>
</table></div>
</div>

View File

@ -1,7 +1,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Compile time log2 Calculation</title>
<title>Compile Time log2 Calculation</title>
<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
<link rel="home" href="../index.html" title="Boost.Integer">
@ -24,12 +24,11 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile time log2 Calculation"> Compile time log2 Calculation</a>
<a name="boost_integer.log2"></a><a class="link" href="log2.html" title="Compile Time log2 Calculation"> Compile Time log2 Calculation</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="log2.html#boost_integer.log2.synopsis">Synopsis</a></span></dt>
<dt><span class="section"><a href="log2.html#boost_integer.log2.usage">Usage</a></span></dt>
<dt><span class="section"><a href="log2.html#boost_integer.log2.example">Example</a></span></dt>
<dt><span class="section"><a href="log2.html#boost_integer.log2.demonstration_program">Demonstration
Program</a></span></dt>
<dt><span class="section"><a href="log2.html#boost_integer.log2.rationale">Rationale</a></span></dt>
@ -75,7 +74,7 @@
The <code class="literal">boost::static_log2</code> class template takes one template
parameter, a value of type <code class="literal">static_log2_argument_type</code>.
The template only defines one member, <code class="literal">value</code>, which gives
the truncated base-two logarithm of the template argument.
the truncated, base-two logarithm of the template argument.
</p>
<p>
Since the logarithm of zero, for any base, is undefined, there is a specialization
@ -99,38 +98,6 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.log2.example"></a><a class="link" href="log2.html#boost_integer.log2.example" title="Example">Example</a>
</h3></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="string">"boost/integer/static_log2.hpp"</span>
<span class="keyword">template</span> <span class="special">&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_log2_argument_type</span> <span class="identifier">value</span> <span class="special">&gt;</span>
<span class="keyword">bool</span> <span class="identifier">is_it_what</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_log2</span><span class="special">&lt;</span><span class="identifier">value</span><span class="special">&gt;</span> <span class="identifier">lb_type</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">temp</span> <span class="special">=</span> <span class="identifier">lb_type</span><span class="special">::</span><span class="identifier">value</span><span class="special">;</span>
<span class="comment">//...
</span> <span class="keyword">return</span> <span class="special">(</span><span class="identifier">temp</span> <span class="special">%</span> <span class="number">2</span><span class="special">)</span> <span class="special">!=</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
<span class="comment">//...
</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
<span class="keyword">bool</span> <span class="identifier">temp</span> <span class="special">=</span> <span class="identifier">is_it_what</span><span class="special">&lt;</span><span class="number">2000</span><span class="special">&gt;();</span>
<span class="comment">//...
</span><span class="preprocessor"># if</span> <span class="number">0</span>
<span class="identifier">temp</span> <span class="special">=</span> <span class="identifier">is_it_what</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;();</span> <span class="comment">// would give an error
</span><span class="preprocessor"># endif</span>
<span class="comment">//...
</span> <span class="identifier">temp</span> <span class="special">=</span> <span class="identifier">is_it_what</span><span class="special">&lt;</span><span class="number">24</span><span class="special">&gt;();</span>
<span class="comment">//...
</span><span class="special">}</span>
</pre>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_integer.log2.demonstration_program"></a><a class="link" href="log2.html#boost_integer.log2.demonstration_program" title="Demonstration Program">Demonstration
Program</a>
</h3></div></div></div>
@ -150,7 +117,7 @@
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 (<span class="emphasis"><em>i.e.</em></span> at compile-time) available.
to be available statically (<span class="emphasis"><em>i.e.</em></span> at compile-time).
</p>
</div>
<div class="section" lang="en">

View File

@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="integer.html" title="Integer Type Selection">
<link rel="next" href="log2.html" title="Compile time log2 Calculation">
<link rel="next" href="log2.html" title="Compile Time log2 Calculation">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@ -105,7 +105,7 @@
of <code class="literal">high_bit_mask_t</code>.
</p>
<div class="table">
<a name="id769480"></a><p class="title"><b>Table&#160;2.&#160;Members of the `boost::high_bit_mask_t` Class Template</b></p>
<a name="id765275"></a><p class="title"><b>Table&#160;2.&#160;Members of the `boost::high_bit_mask_t` Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the `boost::high_bit_mask_t` Class Template">
<colgroup>
<col>
@ -132,7 +132,7 @@
</td>
<td>
<p>
The smallest unsigned built-in type that supports the given bit position.
The smallest, unsigned, built-in type that supports the given bit position.
</p>
</td>
</tr>
@ -144,7 +144,7 @@
</td>
<td>
<p>
The quick-to-manipulate analog of <code class="literal">least</code>.
The easiest-to-manipulate analog of <code class="literal">least</code>.
</p>
</td>
</tr>
@ -156,7 +156,7 @@
</td>
<td>
<p>
A <code class="literal">least</code> constant of the desired bit-masking value.
A <code class="literal">least</code> constant of the value 2<sup>Bit</sup>.
</p>
</td>
</tr>
@ -197,15 +197,14 @@
</h3></div></div></div>
<p>
The <code class="literal">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>Bits</sup> - 1), where <code class="literal">Bits</code> is
the template parameter. The bit amount must be a nonnegative number from
zero to <span class="emphasis"><em>Max</em></span>, where Max 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 class="literal">low_bits_mask_t</code>.
for bit masks equivalent to the value (2<sup>Bits</sup> - 1), where <code class="literal">Bits</code>
is the template parameter. The parameter <code class="literal">Bits</code> must be
a non-negative integer from zero to <span class="emphasis"><em>Max</em></span>, where Max is
the number of bits supported by the largest, unsigned, built-in integral
type. The following table describes the members of <code class="literal">low_bits_mask_t</code>.
</p>
<div class="table">
<a name="id769682"></a><p class="title"><b>Table&#160;3.&#160;Members of the [^boost::low_bits_mask_t] Class Template</b></p>
<a name="id765484"></a><p class="title"><b>Table&#160;3.&#160;Members of the [^boost::low_bits_mask_t] Class Template</b></p>
<div class="table-contents"><table class="table" summary="Members of the [^boost::low_bits_mask_t] Class Template">
<colgroup>
<col>
@ -232,7 +231,7 @@
</td>
<td>
<p>
The smallest unsigned built-in type that supports the given bit count.
The smallest, unsigned built-in type that supports the given bit count.
</p>
</td>
</tr>
@ -244,7 +243,7 @@
</td>
<td>
<p>
The quick-to-manipulate analog of <code class="literal">least</code>.
The easiest-to-manipulate analog of <code class="literal">least</code>.
</p>
</td>
</tr>

View File

@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
<link rel="home" href="../index.html" title="Boost.Integer">
<link rel="up" href="../index.html" title="Boost.Integer">
<link rel="prev" href="log2.html" title="Compile time log2 Calculation">
<link rel="prev" href="log2.html" title="Compile Time log2 Calculation">
<link rel="next" href="history.html" title="History">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@ -71,10 +71,10 @@
</h3></div></div></div>
<p>
The four class templates provide the combinations for finding the minimum
or maximum of two signed or <code class="literal">unsigned</code> (<code class="literal">long</code>)
parameters, Value1 and Value2, at compile-time. Each template has a single
static data member, <code class="literal">value</code>, which is set to the respective
minimum or maximum of the template's parameters.
or maximum of two <code class="literal">signed</code> or <code class="literal">unsigned</code>
(<code class="literal">long</code>) parameters, <span class="emphasis"><em>Value1</em></span> and <span class="emphasis"><em>Value2</em></span>,
at compile-time. Each template has a single static data member, <code class="literal">value</code>,
which is set to the respective minimum or maximum of the template's parameters.
</p>
</div>
<div class="section" lang="en">

View File

@ -70,6 +70,7 @@
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">integer_traits</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
<span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_integral</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
<span class="comment">//
</span> <span class="comment">// These members are defined only if T is a built-in
@ -87,9 +88,9 @@
</h3></div></div></div>
<p>
Template class <code class="literal">integer_traits</code> is derived from <code class="literal">std::numeric_limits</code>.
In general, it adds the single <code class="literal">bool</code> member <code class="literal">is_integral</code>
with the compile-time constant value <code class="literal">false</code>. However, for
all integral types <code class="literal">T</code> (std::3.9.1/7 [basic.fundamental]),
The primary specialization adds the single <code class="literal">bool</code> member
<code class="literal">is_integral</code> with the compile-time constant value <code class="literal">false</code>.
However, for all integral types <code class="literal">T</code> (std::3.9.1/7 [basic.fundamental]),
there are specializations provided with the following compile-time constants
defined:
</p>
@ -171,11 +172,11 @@
</tbody>
</table></div>
<p>
Note: A flag <code class="literal">is_integral</code> is provided, because a user-defined
Note: The <span class="emphasis"><em>is_integral</em></span> flag is provided, because a user-defined
integer class should specialize <code class="literal">std::numeric_limits&lt;&gt;::is_integer
= true</code>, nonetheless compile-time constants <code class="literal">const_min</code>
and <code class="literal">const_max</code> cannot be provided for that user-defined
class.
= true</code>, while compile-time constants <code class="literal">const_min</code>
and <code class="literal">const_max</code> are not provided for that user-defined class,
unless boost::integer_traits is also specialized.
</p>
</div>
<div class="section" lang="en">

View File

@ -40,7 +40,7 @@
<div><p class="copyright">Copyright &#169; 2001 -2009 Beman Dawes, Daryle Walker, Gennaro Prota,
John Maddock</p></div>
<div><div class="legalnotice">
<a name="id758110"></a><p>
<a name="id753741"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
@ -56,7 +56,7 @@
<dt><span class="section"><a href="boost_integer/traits.html"> Integer Traits</a></span></dt>
<dt><span class="section"><a href="boost_integer/integer.html"> Integer Type Selection</a></span></dt>
<dt><span class="section"><a href="boost_integer/mask.html"> Integer Masks</a></span></dt>
<dt><span class="section"><a href="boost_integer/log2.html"> Compile time log2 Calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/log2.html"> Compile Time log2 Calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/minmax.html"> Compile time min/max calculation</a></span></dt>
<dt><span class="section"><a href="boost_integer/history.html"> History</a></span></dt>
</dl>
@ -66,7 +66,15 @@
<a name="boost_integer.overview"></a><a class="link" href="index.html#boost_integer.overview" title="Overview"> Overview</a>
</h2></div></div></div>
<p>
Boost.Integer consists of the following components:
Boost.Integer provides integer type support, particularly helpful in generic
programming. It provides standard C99 integer types, such as might be found
in &lt;stdint.h&gt;, without requiring that header. It provides the means to
select an integer type based upon its properties, like the number of bits or
the maximum supported value, as well as compile-time bit mask selection. There
is a derivative of std::numeric_limits that provides integral constant expressions
for <code class="computeroutput"><span class="identifier">min</span></code> and <code class="computeroutput"><span class="identifier">max</span></code>.
Finally, it provides two compile-time algorithms: determining the highest power
of two in a compile-time value; and computing min and max of constant expressions.
</p>
<div class="informaltable"><table class="table">
<colgroup>
@ -191,7 +199,7 @@
<tr>
<td>
<p>
<a class="link" href="boost_integer/log2.html" title="Compile time log2 Calculation">Compile time log2 Calculation</a>.
<a class="link" href="boost_integer/log2.html" title="Compile Time log2 Calculation">Compile time log2 Calculation</a>.
</p>
</td>
<td>
@ -229,7 +237,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 27, 2009 at 11:11:24 GMT</small></p></td>
<td align="left"><p><small>Last revised: November 28, 2009 at 17:06:38 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -15,7 +15,13 @@
[section:overview Overview]
Boost.Integer consists of the following components:
Boost.Integer provides integer type support, particularly helpful in generic programming. It provides standard
C99 integer types, such as might be found in <stdint.h>, without requiring that header.
It provides the means to select an integer type based upon its properties, like the number of bits or
the maximum supported value, as well as compile-time bit mask selection. There is a derivative of
std::numeric_limits that provides integral constant expressions for `min` and `max`.
Finally, it provides two compile-time algorithms: determining the highest power of two in a
compile-time value; and computing min and max of constant expressions.
[table
[[Component][Header][Purpose]]
@ -71,9 +77,9 @@ Boost.Integer consists of the following components:
The header [^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]] provides the typedef's useful
for writing portable code that requires certain integer widths. All typedef's are in namespace boost.
The specifications are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
The 64-bit types required by the C standard are not required in the boost header,
and may not be supplied in all implementations, because [^long long] is not [yet] included in the C++ standard.
The specifications for these types are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
The 64-bit types required by the C standard are ['not required] in the boost header,
and may not be supplied for all platforms/compilers, because [^long long] is not [yet] included in the C++ standard.
See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
@ -82,9 +88,9 @@ See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
[section:rationale Rationale]
The organization of the Boost.Integer headers and classes is designed to take advantage of <stdint.h> types from the
1999 C standard without resorting to undefined behavior in terms of the 1998 C++ standard.
1999 C standard without causing undefined behavior in terms of the 1998 C++ standard.
The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace [^boost]
without placing any names in namespace [^std]. As always, the intension is to complement rather than compete
without placing any names in namespace [^std]. The intension is to complement rather than compete
with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>,
then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.
@ -111,8 +117,9 @@ The typedef [^int#_t], with # replaced by the width, designates a signed integer
for example [^int8_t] denotes an 8-bit signed integer type. Similarly, the typedef [^uint#_t] designates an unsigned
integer type of exactly # bits.
These types are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits,
it shall define the corresponding typedef names.
These types are optional. However, if a platform supports integer types with widths of
8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> does provide the
corresponding typedefs.
The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`.
@ -122,11 +129,11 @@ The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`
The typedef [^int_least#_t], with # replaced by the width, designates a signed integer type with a width
of at least # bits, such that no signed integer type with lesser size has at least the specified width.
Thus, [^int_least32_t] denotes a signed integer type with a width of at least 32 bits.
Thus, [^int_least32_t] denotes the smallest signed integer type with a width of at least 32 bits.
Similarly, the typedef name [^uint_least#_t] designates an unsigned integer type with a width of at least # bits,
such that no unsigned integer type with lesser size has at least the specified width.
Required minimum-width integer types:
The following minimum-width integer types are provided for all platforms:
* [^int_least8_t]
* [^int_least16_t]
@ -135,12 +142,11 @@ Required minimum-width integer types:
* [^uint_least16_t]
* [^uint_least32_t]
The types:
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
* [^int_least64_t]
* [^uint_least64_t]
Are available only if, after inclusion of [^<boost/cstdint.hpp>] the macro `BOOST_NO_INT64_T` is ['[*not defined]].
All other minimum-width integer types are optional.
@ -155,7 +161,7 @@ unsigned integer type with a width of at least # bits.
There is no guarantee that these types are fastest for all purposes. In any case, however, they satisfy
the signedness and width requirements.
Required fastest minimum-width integer types:
The following fastest minimum-width integer types are provided for all platforms:
* [^int_fast8_t]
* [^int_fast16_t]
@ -164,13 +170,11 @@ Required fastest minimum-width integer types:
* [^uint_fast16_t]
* [^uint_fast32_t]
The types:
The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
* [^int_fast64_t]
* [^uint_fast64_t]
Are available only if, after inclusion of [^<boost/cstdint.hpp>] the macro `BOOST_NO_INT64_T` is ['[*not defined]].
All other fastest minimum-width integer types are optional.
[endsect]
@ -181,7 +185,7 @@ The typedef [^intmax_t ]designates a signed integer type capable of representing
The typedef [^uintmax_t] designates an unsigned integer type capable of representing any value of any unsigned integer type.
These types are required.
These types are provided for all platforms.
[endsect]
[endsect]
@ -216,6 +220,7 @@ The template class [^integer_traits] addresses this problem.
template<class T>
class integer_traits : public std::numeric_limits<T>
{
public:
static const bool is_integral = false;
//
// These members are defined only if T is a built-in
@ -230,7 +235,7 @@ The template class [^integer_traits] addresses this problem.
[section Description]
Template class [^integer_traits] is derived from [^std::numeric_limits]. In general, it adds the single
Template class [^integer_traits] is derived from [^std::numeric_limits]. The primary specialization adds the single
[^bool] member [^is_integral] with the compile-time constant value [^false].
However, for all integral types [^T] (std::3.9.1/7 [basic.fundamental]), there are specializations
provided with the following compile-time constants defined:
@ -242,9 +247,9 @@ provided with the following compile-time constants defined:
[[[^const_max]][[^T]][equivalent to [^std::numeric_limits<T>::max()]]]
]
Note: A flag [^is_integral] is provided, because a user-defined integer class should specialize
[^std::numeric_limits<>::is_integer = true], nonetheless compile-time constants
[^const_min] and [^const_max] cannot be provided for that user-defined class.
Note: The /is_integral/ flag is provided, because a user-defined integer class should specialize
[^std::numeric_limits<>::is_integer = true], while compile-time constants
[^const_min] and [^const_max] are not provided for that user-defined class, unless boost::integer_traits is also specialized.
[endsect]
@ -275,7 +280,7 @@ This facility is particularly useful for solving generic programming problems.
template<typename LeastInt>
struct int_fast_t
{
typedef ``['implementation-defined-type]`` fast;
typedef ``['implementation-defined-type]`` type;
};
// signed
@ -330,12 +335,12 @@ The [^int_fast_t] class template maps its input type to the next-largest type th
can manipulate the easiest, or to itself if the input type is already an easy-to-manipulate type.
For instance, processing a bunch of [^char] objects may go faster if they were converted to [^int] objects before processing.
The input type, passed as the only template parameter, must be a built-in integral type, except [^bool].
Unsigned integral types can be used, as well as signed integral types, despite the name.
The output type is given as the class member [^fast].
Unsigned integral types can be used, as well as signed integral types.
The output type is given as the nested type [^fast].
[*Implementation Notes:]
By default, the output type is identical to the input type. Eventually, this code's implementation should
be conditionalized for each platform to give accurate mappings between the built-in types and the easiest-to-manipulate
be customized 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.
[endsect]
@ -344,7 +349,7 @@ built-in types. Also, there is no guarantee that the output type actually is eas
The [^int_t], [^uint_t], [^int_max_value_t], [^int_min_value_t], and [^uint_value_t] class templates find
the most appropiate built-in integral type for the given template parameter. This type is given by the
class member [^least]. The easiest-to-manipulate version of that type is given by the class member [^fast].
nested type [^least]. The easiest-to-manipulate version of that type is given by the nested type [^fast].
The following table describes each template's criteria.
[table Criteria for the Sized Type Class Templates
@ -352,33 +357,71 @@ The following table describes each template's criteria.
[Class Template][Template Parameter Mapping]
]
[
[[^boost::int_t<N>]]
[The smallest built-in signed integral type with at least /N/ bits, including the sign bit.
[[^boost::int_t<N>::least]]
[The smallest, built-in, signed integral type with at least /N/ bits, including the sign bit.
The parameter should be a positive number. A compile-time error results if the parameter is
larger than the number of bits in the largest integer type. Note that the member /exact/ is defined
[*only] if there is a type with exactly N bits.]
larger than the number of bits in the largest integer type.]
]
[
[[^boost::uint_t<N>]]
[The smallest built-in unsigned integral type with at least /N/ bits.
[[^boost::int_t<N>::fast]]
[The easiest-to-manipulate, built-in, signed integral type with at least /N/ bits, including the sign bit.
The parameter should be a positive number. A compile-time error results if the parameter is
larger than the number of bits in the largest integer type.]
]
[
[[^boost::int_t<N>::exact]]
[A built-in, signed integral type with exactly /N/ bits, including the sign bit.
The parameter should be a positive number. Note that the member /exact/ is defined
[*only] if there exists a type with exactly /N/ bits.]
]
[
[[^boost::uint_t<N>::least]]
[The smallest, built-in, unsigned integral type with at least /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.]
]
[
[[^boost::uint_t<N>::fast]]
[The easiest-to-manipulate, built-in, unsigned integral type with at least /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.]
]
[
[[^boost::uint_t<N>::exact]]
[A built-in, unsigned integral type with exactly /N/ bits.
The parameter should be a positive number. A compile-time error results if the
parameter is larger than the number of bits in the largest integer type.
Note that the member /exact/ is defined
[*only] if there is a type with exactly N bits.]
[*only] if there exists a type with exactly N bits.]
]
[
[[^boost::int_max_value_t<V>]]
[The smallest built-in signed integral type that can hold all the values in the inclusive range ['0 - V].
[[^boost::int_max_value_t<V>::last]]
[The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
The parameter should be a positive number.]
]
[
[[^boost::int_min_value_t<V>]]
[The smallest built-in signed integral type that can hold all the values in the inclusive range ['V-0].
[[^boost::int_max_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['0 - V].
The parameter should be a positive number.]
]
[
[[^boost::int_min_value_t<V>::least]]
[The smallest, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
The parameter should be a negative number.]
]
[
[[^boost::uint_value_t<V>]]
[The smallest built-in unsigned integral type that can hold all positive values
[[^boost::int_min_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, signed integral type that can hold all the values in the inclusive range ['V - 0].
The parameter should be a negative number.]
]
[
[[^boost::uint_value_t<V>::least]]
[The smallest, built-in, unsigned integral type that can hold all positive values
up to and including /V/. The parameter should be a positive number.]
]
[
[[^boost::uint_value_t<V>::fast]]
[The easiest-to-manipulate, built-in, unsigned integral type that can hold all positive values
up to and including /V/. The parameter should be a positive number.]
]
]
@ -500,9 +543,9 @@ the members of an instantiation of [^high_bit_mask_t].
[table Members of the `boost::high_bit_mask_t` Class Template
[[Member][Meaning]]
[[[^least]][The smallest unsigned built-in type that supports the given bit position.]]
[[[^fast]][The quick-to-manipulate analog of [^least].]]
[[[^high_bit]][A [^least] constant of the desired bit-masking value.]]
[[[^least]][The smallest, unsigned, built-in type that supports the given bit position.]]
[[[^fast]][The easiest-to-manipulate analog of [^least].]]
[[[^high_bit]][A [^least] constant of the value 2[super Bit].]]
[[[^high_bit_fast]][A [^fast] analog of [^high_bit].]]
[[[^bit_position]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
]
@ -511,16 +554,16 @@ the members of an instantiation of [^high_bit_mask_t].
[section Group Bit-Mask Class Template]
The [^boost::low_bits_mask_t] class template provides constants for bit masks representing the lowest
bits of a certain amount. The masks are equivalent to the value (2[super Bits] - 1),
where [^Bits] is the template parameter. The bit amount must be a nonnegative number from
zero to ['Max], where Max is the number of bits supported by the largest unsigned built-in integral type.
The following table describes the members of an instantiation of [^low_bits_mask_t].
The [^boost::low_bits_mask_t] class template provides constants for bit masks
equivalent to the value (2[super Bits] - 1), where [^Bits] is the template parameter.
The parameter [^Bits] must be a non-negative integer from
zero to ['Max], where Max is the number of bits supported by the largest, unsigned, built-in integral type.
The following table describes the members of [^low_bits_mask_t].
[table Members of the [^boost::low_bits_mask_t] Class Template
[[Member][Meaning]]
[[[^least]][The smallest unsigned built-in type that supports the given bit count.]]
[[[^fast]][The quick-to-manipulate analog of [^least].]]
[[[^least]][The smallest, unsigned built-in type that supports the given bit count.]]
[[[^fast]][The easiest-to-manipulate analog of [^least].]]
[[[^sig_bits]][A [^least] constant of the desired bit-masking value.]]
[[[^sig_bits_fast]][A [^fast] analog of [^sig_bits].]]
[[[^bit_count]][The value of the template parameter, in case its needed from a renamed instantiation of the class template.]]
@ -581,7 +624,7 @@ The author of the Boost bit mask class templates is [@http://www.boost.org/peopl
[endsect]
[endsect]
[section:log2 Compile time log2 Calculation]
[section:log2 Compile Time log2 Calculation]
The class template in [@../../../../boost/integer/static_log2.hpp <boost/integer/static_log2.hpp>]
determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.
@ -616,7 +659,7 @@ determines the position of the highest bit in a given value. This facility is us
The [^boost::static_log2] class template takes one template parameter, a value of type
[^static_log2_argument_type]. The template only defines one member, [^value], which gives the
truncated base-two logarithm of the template argument.
truncated, base-two logarithm of the template argument.
Since the logarithm of zero, for any base, is undefined, there is a specialization of [^static_log2]
for a template argument of zero. This specialization has no members, so an attempt to use the base-two
@ -629,37 +672,6 @@ Note:
[endsect]
[section Example]
#include "boost/integer/static_log2.hpp"
template < boost::static_log2_argument_type 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>();
//...
}
[endsect]
[section Demonstration Program]
The program [@../../test/static_log2_test.cpp static_log2_test.cpp] is a simplistic
@ -672,7 +684,7 @@ demonstration of the results from instantiating various examples of the binary l
The base-two (binary) logarithm, abbreviated lb, 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.e.] at compile-time) available.
could be used in generic programming, which requires the position to be available statically (['i.e.] at compile-time).
[endsect]
@ -719,8 +731,8 @@ for generic programming problems.
[section Usage]
The four class templates provide the combinations for finding the minimum or maximum of two signed or
[^unsigned] ([^long]) parameters, Value1 and Value2, at compile-time. Each template has a single static data member,
The four class templates provide the combinations for finding the minimum or maximum of two [^signed] or
[^unsigned] ([^long]) parameters, /Value1/ and /Value2/, at compile-time. Each template has a single static data member,
[^value], which is set to the respective minimum or maximum of the template's parameters.
[endsect]