Rearranges rows and columns in tables. Add big_int8_t, big_uint8_t, little_int8_t, little_uint8_t arithmetic and buffer types, in response to mini-review query.

This commit is contained in:
Beman
2015-02-16 19:31:48 -05:00
parent d0dc573ec1
commit b0ef03b9d6
6 changed files with 169 additions and 147 deletions

View File

@@ -213,126 +213,126 @@ enum class align {no, yes}; </pre>
class endian_arithmetic; class endian_arithmetic;
</pre> </pre>
</blockquote> </blockquote>
<p>Typedefs, such as <code>big_int32_t</code>, provide convenient naming <p>Typedefs, such as <code>big_int32_ut</code>, provide convenient naming
conventions for common use cases:</p> conventions for common use cases:</p>
<blockquote> <blockquote>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%"> <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%">
<tr> <tr>
<td width="18%" align="center"><b><i>Name</i></b></td> <td width="18%" align="center"><b><i>Name</i></b></td>
<td width="10%" align="center"><b><i>Endianness</i></b></td>
<td width="49%" align="center"><b><i>Alignment</i></b></td> <td width="49%" align="center"><b><i>Alignment</i></b></td>
<td width="10%" align="center"><b><i>Endianness</i></b></td>
<td width="10%" align="center"><b><i>Sign</i></b></td> <td width="10%" align="center"><b><i>Sign</i></b></td>
<td width="15%" align="center"><b><i>Sizes in bits (n)</i></b></td> <td width="15%" align="center"><b><i>Sizes in bits (n)</i></b></td>
</tr> </tr>
<tr>
<td width="18%"><code>big_int</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">16,32,64</td>
</tr>
<tr>
<td width="18%"><code>big_uint</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">16,32,64</td>
</tr>
<tr>
<td width="18%"><code>big_float</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr> <tr>
<td width="18%"><code>big_int</code><b><i>n</i></b><code>_ut</code></td> <td width="18%"><code>big_int</code><b><i>n</i></b><code>_ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>big_uint</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>big_uint</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">unsigned</td> <td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>big_float</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>big_float</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
</tr> </tr>
<tr>
<td width="18%"><code>little_int</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">16,32,64</td>
</tr>
<tr>
<td width="18%"><code>little_uint</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">16,32,64</td>
</tr>
<tr>
<td width="18%"><code>little_float</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr> <tr>
<td width="18%"><code>little_int</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>little_int</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>little_uint</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>little_uint</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">unsigned</td> <td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>little_float</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>little_float</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
</tr> </tr>
<tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_t</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr> <tr>
<td width="18%"><code>native_int</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>native_int</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>native_uint</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>native_uint</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">unsigned</td> <td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td> <td width="15%">8,16,24,32,40,48,56,64</td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_ut</code></td> <td width="18%"><code>native_float</code><i><b>n</b></i><code>_ut</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="49%" align="center"><code>no</code></td> <td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr>
<td width="18%"><code>big_int</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,32,64</td>
</tr>
<tr>
<td width="18%"><code>big_uint</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,32,64</td>
</tr>
<tr>
<td width="18%"><code>big_float</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr>
<td width="18%" dir="ltr"><code>little_int</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center" dir="ltr"><code>yes</code></td>
<td width="10%" align="center" dir="ltr"><code>little</code></td>
<td width="10%" align="center" dir="ltr">signed</td>
<td width="15%" dir="ltr">8,16,32,64</td>
</tr>
<tr>
<td width="18%" dir="ltr"><code>little_uint</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center" dir="ltr"><code>yes</code></td>
<td width="10%" align="center" dir="ltr"><code>little</code></td>
<td width="10%" align="center" dir="ltr">unsigned</td>
<td width="15%" dir="ltr">8,16,32,64</td>
</tr>
<tr>
<td width="18%" dir="ltr"><code>little_float</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center" dir="ltr"><code>yes</code></td>
<td width="10%" align="center" dir="ltr"><code>little</code></td>
<td width="10%" align="center" dir="ltr">signed</td>
<td width="15%" dir="ltr">32,64</td>
</tr>
<tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
</tr> </tr>
@@ -346,15 +346,16 @@ Code that uses a</span>ligned types is possibly non-portable because alignment
requirements vary between hardware architectures and because alignment may be requirements vary between hardware architectures and because alignment may be
affected by compiler switches or pragmas. For example, alignment of an 64-bit affected by compiler switches or pragmas. For example, alignment of an 64-bit
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
are only available on architectures with 16, 32, and 64-bit integer types.</p> are only available on architectures with 8, 16, 32, and 64-bit integer types.</p>
<p><i><b>Recommendation:</b></i> Prefer unaligned endian types.</p>
<p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For <p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For
example:</p> example:</p>
<blockquote> <blockquote>
<pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre> <pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre>
</blockquote> </blockquote>
<p><b><i>Note:</i></b> One-byte types <p><b><i>Note:</i></b> One-byte big and little buffer types
have identical never actually reverse endianness. They are provided to enable generic code, and
functionality. They are provided to improve code readability and searchability.</p> to improve code readability and searchability.</p>
<h2><a name="Class_template_endian">Class template <code>endian</code></a><code>_arithmetic</code></h2> <h2><a name="Class_template_endian">Class template <code>endian</code></a><code>_arithmetic</code></h2>
<p>An endian is an integer byte-holder with user-specified <a href="#endianness"> <p>An endian is an integer byte-holder with user-specified <a href="#endianness">
endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The
@@ -443,21 +444,25 @@ usual operations on integers are supplied.</p>
typedef endian&lt;order::little, double, 64, align::no&gt; little_float64_ut; typedef endian&lt;order::little, double, 64, align::no&gt; little_float64_ut;
// aligned big endian signed integer types // aligned big endian signed integer types
typedef endian&lt;order::big, int8_t, 8, align::yes&gt; big_int8_t;
typedef endian&lt;order::big, int16_t, 16, align::yes&gt; big_int16_t; typedef endian&lt;order::big, int16_t, 16, align::yes&gt; big_int16_t;
typedef endian&lt;order::big, int32_t, 32, align::yes&gt; big_int32_t; typedef endian&lt;order::big, int32_t, 32, align::yes&gt; big_int32_t;
typedef endian&lt;order::big, int64_t, 64, align::yes&gt; big_int64_t; typedef endian&lt;order::big, int64_t, 64, align::yes&gt; big_int64_t;
// aligned big endian unsigned integer types // aligned big endian unsigned integer types
typedef endian&lt;order::big, uint8_t, 8, align::yes&gt; big_uint8_t;
typedef endian&lt;order::big, uint16_t, 16, align::yes&gt; big_uint16_t; typedef endian&lt;order::big, uint16_t, 16, align::yes&gt; big_uint16_t;
typedef endian&lt;order::big, uint32_t, 32, align::yes&gt; big_uint32_t; typedef endian&lt;order::big, uint32_t, 32, align::yes&gt; big_uint32_t;
typedef endian&lt;order::big, uint64_t, 64, align::yes&gt; big_uint64_t; typedef endian&lt;order::big, uint64_t, 64, align::yes&gt; big_uint64_t;
// aligned little endian signed integer types // aligned little endian signed integer types
typedef endian&lt;order::little, int8_t, 8, align::yes&gt; little_int8_t;
typedef endian&lt;order::little, int16_t, 16, align::yes&gt; little_int16_t; typedef endian&lt;order::little, int16_t, 16, align::yes&gt; little_int16_t;
typedef endian&lt;order::little, int32_t, 32, align::yes&gt; little_int32_t; typedef endian&lt;order::little, int32_t, 32, align::yes&gt; little_int32_t;
typedef endian&lt;order::little, int64_t, 64, align::yes&gt; little_int64_t; typedef endian&lt;order::little, int64_t, 64, align::yes&gt; little_int64_t;
// aligned little endian unsigned integer types // aligned little endian unsigned integer types
typedef endian&lt;order::little, uint8_t, 8, align::yes&gt; little_uint8_t;
typedef endian&lt;order::little, uint16_t, 16, align::yes&gt; little_uint16_t; typedef endian&lt;order::little, uint16_t, 16, align::yes&gt; little_uint16_t;
typedef endian&lt;order::little, uint32_t, 32, align::yes&gt; little_uint32_t; typedef endian&lt;order::little, uint32_t, 32, align::yes&gt; little_uint32_t;
typedef endian&lt;order::little, uint64_t, 64, align::yes&gt; little_uint64_t; typedef endian&lt;order::little, uint64_t, 64, align::yes&gt; little_uint64_t;
@@ -682,7 +687,7 @@ differs from endian representation size. Vicente Botet and other reviewers
suggested supporting floating point types.</p> suggested supporting floating point types.</p>
<hr> <hr>
<p>Last revised: <p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38896" --></p> <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->12 February, 2015<!--webbot bot="Timestamp" endspan i-checksum="40531" --></p>
<p>© Copyright Beman Dawes, 2006-2009, 2013</p> <p>© Copyright Beman Dawes, 2006-2009, 2013</p>
<p>Distributed under the Boost Software License, Version 1.0. See <p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p> <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>

View File

@@ -200,128 +200,128 @@ enum class align {no, yes}; </pre>
class endian_buffer; class endian_buffer;
</pre> </pre>
</blockquote> </blockquote>
<p>Typedefs, such as <code>big_int32_buf_t</code>, provide convenient naming <p>Typedefs, such as <code>big_int32_buf_ut</code>, provide convenient naming
conventions for common use cases:</p> conventions for common use cases:</p>
<blockquote> <blockquote>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%"> <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%">
<tr> <tr>
<td width="18%" align="center"><b><i>Name</i></b></td> <td width="18%" align="center"><b><i>Name</i></b></td>
<td width="49%" align="center"><b><i>Alignment</i></b></td>
<td width="10%" align="center"><b><i>Endianness</i></b></td> <td width="10%" align="center"><b><i>Endianness</i></b></td>
<td width="10%" align="center"><b><i>Sign</i></b></td> <td width="10%" align="center"><b><i>Sign</i></b></td>
<td width="15%" align="center"><b><i>Sizes in bits (n)</i></b></td> <td width="15%" align="center"><b><i>Sizes in bits (n)</i></b></td>
<td width="49%" align="center"><b><i>Alignment</i></b></td>
</tr> </tr>
<tr>
<td width="18%" dir="ltr"><code>big_int</code><b><i>n</i></b><code>_buf_ut</code></td>
<td width="49%" align="center" dir="ltr"><code>no</code></td>
<td width="10%" align="center" dir="ltr"><code>big</code></td>
<td width="10%" align="center" dir="ltr">signed</td>
<td width="15%" dir="ltr">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%" dir="ltr"><code>big_uint</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center" dir="ltr"><code>no</code></td>
<td width="10%" align="center" dir="ltr"><code>big</code></td>
<td width="10%" align="center" dir="ltr">unsigned</td>
<td width="15%" dir="ltr">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%" dir="ltr"><code>big_float</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center" dir="ltr"><code>no</code></td>
<td width="10%" align="center" dir="ltr"><code>big</code></td>
<td width="10%" align="center" dir="ltr">signed</td>
<td width="15%" dir="ltr">32,64</td>
</tr>
<tr>
<td width="18%"><code>little_int</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%"><code>little_uint</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%"><code>little_float</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr>
<td width="18%"><code>native_int</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%"><code>native_uint</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
</tr>
<tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_buf_ut</code></td>
<td width="49%" align="center"><code>no</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
</tr>
<tr> <tr>
<td width="18%"><code>big_int</code><i><b>n</b></i><code>_buf_t</code></td> <td width="18%"><code>big_int</code><i><b>n</b></i><code>_buf_t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td> <td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">16,32,64</td> <td width="15%">8,16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>big_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>big_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td> <td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">unsigned</td> <td width="10%" align="center">unsigned</td>
<td width="15%">16,32,64</td> <td width="15%">8,16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>big_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>big_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>big</code></td> <td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
<td width="49%" align="center"><code>yes</code></td>
</tr> </tr>
<tr>
<td width="18%"><code>big_int</code><b><i>n</i></b><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>big_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>big_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>big</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr> <tr>
<td width="18%"><code>little_int</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>little_int</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>little</code></td> <td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">16,32,64</td> <td width="15%">8,16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>little_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>little_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>little</code></td> <td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">unsigned</td> <td width="10%" align="center">unsigned</td>
<td width="15%">16,32,64</td> <td width="15%">8,16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>little_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>little_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
<td width="49%" align="center"><code>yes</code></td> <td width="49%" align="center"><code>yes</code></td>
</tr>
<tr>
<td width="18%"><code>little_int</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>little_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>little_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>little</code></td> <td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr> </tr>
<tr> <tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td> <td width="18%"><code>native_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>t</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">32,64</td>
<td width="49%" align="center"><code>yes</code></td> <td width="49%" align="center"><code>yes</code></td>
</tr>
<tr>
<td width="18%"><code>native_int</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>native_uint</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">8,16,24,32,40,48,56,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
<tr>
<td width="18%"><code>native_float</code><i><b>n</b></i><code>_</code><code>buf_</code><code>ut</code></td>
<td width="10%" align="center"><code>native</code></td> <td width="10%" align="center"><code>native</code></td>
<td width="10%" align="center">signed</td> <td width="10%" align="center">signed</td>
<td width="15%">32,64</td> <td width="15%">32,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr> </tr>
</table> </table>
</blockquote> </blockquote>
@@ -333,15 +333,16 @@ Code that uses a</span>ligned types is possibly non-portable because alignment
requirements vary between hardware architectures and because alignment may be requirements vary between hardware architectures and because alignment may be
affected by compiler switches or pragmas. For example, alignment of an 64-bit affected by compiler switches or pragmas. For example, alignment of an 64-bit
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
are only available on architectures with 16, 32, and 64-bit integer types. </p> are only available on architectures with 8, 16, 32, and 64-bit integer types. </p>
<p><i><b>Recommendation:</b></i> Prefer unaligned endian types.</p>
<p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For <p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For
example:</p> example:</p>
<blockquote> <blockquote>
<pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre> <pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre>
</blockquote> </blockquote>
<p><b><i>Note:</i></b> One-byte big and little buffer types <p><b><i>Note:</i></b> One-byte big and little buffer types
have identical never actually reverse endianness. They are provided to enable generic code, and
functionality. They are provided to improve code readability and searchability.</p> to improve code readability and searchability.</p>
<h2><a name="Class_template_endian">Class template <code>endian</code></a><code>_buffer</code></h2> <h2><a name="Class_template_endian">Class template <code>endian</code></a><code>_buffer</code></h2>
<p>An <code>endian_buffer</code> is an integer byte-holder with user-specified <a href="#endianness"> <p>An <code>endian_buffer</code> is an integer byte-holder with user-specified <a href="#endianness">
endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The
@@ -655,7 +656,7 @@ any Boost object libraries.</p>
</ul> </ul>
<hr> <hr>
<p>Last revised: <p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38896" --></p> <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->12 February, 2015<!--webbot bot="Timestamp" endspan i-checksum="40531" --></p>
<p>© Copyright Beman Dawes, 2006-2009, 2013</p> <p>© Copyright Beman Dawes, 2006-2009, 2013</p>
<p>Distributed under the Boost Software License, Version 1.0. See <p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p> <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>

View File

@@ -96,21 +96,25 @@ namespace endian
typedef endian_arithmetic<order::little, double, 64, align::no> little_float64_ut; typedef endian_arithmetic<order::little, double, 64, align::no> little_float64_ut;
// big endian signed integer aligned types // big endian signed integer aligned types
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_t;
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_t; typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_t;
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_t; typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_t;
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_t; typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_t;
// big endian unsigned integer aligned types // big endian unsigned integer aligned types
typedef endian_arithmetic<order::big, uint8_t, 8, align::yes> big_uint8_t;
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_t; typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_t;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_t; typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_t;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_t; typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_t;
// little endian signed integer aligned types // little endian signed integer aligned types
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_t;
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_t; typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_t;
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_t; typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_t;
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_t; typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_t;
// little endian unsigned integer aligned types // little endian unsigned integer aligned types
typedef endian_arithmetic<order::little, uint8_t, 8, align::yes> little_uint8_t;
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_t; typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_t;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_t; typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_t;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_t; typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_t;

View File

@@ -93,21 +93,25 @@ namespace endian
typedef endian_buffer<order::little, double, 64, align::no> little_float64_buf_ut; typedef endian_buffer<order::little, double, 64, align::no> little_float64_buf_ut;
// aligned big endian signed integer buffers // aligned big endian signed integer buffers
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_t;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_t; typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_t;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_t; typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_t;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_t; typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_t;
// aligned big endian unsigned integer buffers // aligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_t;
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_t; typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_t;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_t; typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_t;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_t; typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_t;
// aligned little endian signed integer buffers // aligned little endian signed integer buffers
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_t;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_t; typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_t;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_t; typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_t;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_t; typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_t;
// aligned little endian unsigned integer buffers // aligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_t;
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_t; typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_t;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_t; typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_t;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_t; typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_t;

View File

@@ -98,18 +98,22 @@ namespace
BOOST_TEST_EQ(sizeof(native_uint56_buf_ut), 7u); BOOST_TEST_EQ(sizeof(native_uint56_buf_ut), 7u);
BOOST_TEST_EQ(sizeof(native_uint64_buf_ut), 8u); BOOST_TEST_EQ(sizeof(native_uint64_buf_ut), 8u);
BOOST_TEST_EQ(sizeof(big_int8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(big_int16_buf_t), 2u); BOOST_TEST_EQ(sizeof(big_int16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(big_int32_buf_t), 4u); BOOST_TEST_EQ(sizeof(big_int32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(big_int64_buf_t), 8u); BOOST_TEST_EQ(sizeof(big_int64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(big_uint8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(big_uint16_buf_t), 2u); BOOST_TEST_EQ(sizeof(big_uint16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(big_uint32_buf_t), 4u); BOOST_TEST_EQ(sizeof(big_uint32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(big_uint64_buf_t), 8u); BOOST_TEST_EQ(sizeof(big_uint64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(little_int8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(little_int16_buf_t), 2u); BOOST_TEST_EQ(sizeof(little_int16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(little_int32_buf_t), 4u); BOOST_TEST_EQ(sizeof(little_int32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(little_int64_buf_t), 8u); BOOST_TEST_EQ(sizeof(little_int64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(little_uint8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(little_uint16_buf_t), 2u); BOOST_TEST_EQ(sizeof(little_uint16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(little_uint32_buf_t), 4u); BOOST_TEST_EQ(sizeof(little_uint32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(little_uint64_buf_t), 8u); BOOST_TEST_EQ(sizeof(little_uint64_buf_t), 8u);

View File

@@ -402,19 +402,23 @@ namespace
VERIFY_SIZE( sizeof( native_uint56_ut ), 7 ); VERIFY_SIZE( sizeof( native_uint56_ut ), 7 );
VERIFY_SIZE( sizeof( native_uint64_ut ), 8 ); VERIFY_SIZE( sizeof( native_uint64_ut ), 8 );
VERIFY_SIZE( sizeof( big_int16_t ), 2 ); VERIFY_SIZE(sizeof(big_int8_t), 1);
VERIFY_SIZE(sizeof(big_int16_t), 2);
VERIFY_SIZE( sizeof( big_int32_t ), 4 ); VERIFY_SIZE( sizeof( big_int32_t ), 4 );
VERIFY_SIZE( sizeof( big_int64_t ), 8 ); VERIFY_SIZE( sizeof( big_int64_t ), 8 );
VERIFY_SIZE( sizeof( big_uint16_t ), 2 ); VERIFY_SIZE(sizeof(big_uint8_t), 1);
VERIFY_SIZE(sizeof(big_uint16_t), 2);
VERIFY_SIZE( sizeof( big_uint32_t ), 4 ); VERIFY_SIZE( sizeof( big_uint32_t ), 4 );
VERIFY_SIZE( sizeof( big_uint64_t ), 8 ); VERIFY_SIZE( sizeof( big_uint64_t ), 8 );
VERIFY_SIZE( sizeof( little_int16_t ), 2 ); VERIFY_SIZE(sizeof(little_int8_t), 1);
VERIFY_SIZE(sizeof(little_int16_t), 2);
VERIFY_SIZE( sizeof( little_int32_t ), 4 ); VERIFY_SIZE( sizeof( little_int32_t ), 4 );
VERIFY_SIZE( sizeof( little_int64_t ), 8 ); VERIFY_SIZE( sizeof( little_int64_t ), 8 );
VERIFY_SIZE( sizeof( little_uint16_t ), 2 ); VERIFY_SIZE(sizeof(little_uint8_t), 1);
VERIFY_SIZE(sizeof(little_uint16_t), 2);
VERIFY_SIZE( sizeof( little_uint32_t ), 4 ); VERIFY_SIZE( sizeof( little_uint32_t ), 4 );
VERIFY_SIZE( sizeof( little_uint64_t ), 8 ); VERIFY_SIZE( sizeof( little_uint64_t ), 8 );
} // check_size } // check_size