copy from develop

This commit is contained in:
Beman
2015-02-16 19:33:45 -05:00
parent 2663fc447c
commit 3aa5873c05
4 changed files with 178 additions and 162 deletions

View File

@@ -213,126 +213,126 @@ enum class align {no, yes}; </pre>
class endian_arithmetic;
</pre>
</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>
<blockquote>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%">
<tr>
<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="10%" align="center"><b><i>Endianness</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>
</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>
<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="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>
</tr>
<tr>
<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="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>
</tr>
<tr>
<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="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%"><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>
<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="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>_ut</code></td>
<td width="10%" align="center"><code>little</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>_ut</code></td>
<td width="10%" align="center"><code>little</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_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>
<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="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>_ut</code></td>
<td width="10%" align="center"><code>native</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>_ut</code></td>
<td width="10%" align="center"><code>native</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="15%">32,64</td>
</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
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
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
example:</p>
<blockquote>
<pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre>
</blockquote>
<p><b><i>Note:</i></b> One-byte types
have identical
functionality. They are provided to improve code readability and searchability.</p>
<p><b><i>Note:</i></b> One-byte big and little buffer types
never actually reverse endianness. They are provided to enable generic code, and
to improve code readability and searchability.</p>
<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">
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;
// 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, int32_t, 32, align::yes&gt; big_int32_t;
typedef endian&lt;order::big, int64_t, 64, align::yes&gt; big_int64_t;
// 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, uint32_t, 32, align::yes&gt; big_uint32_t;
typedef endian&lt;order::big, uint64_t, 64, align::yes&gt; big_uint64_t;
// 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, int32_t, 32, align::yes&gt; little_int32_t;
typedef endian&lt;order::little, int64_t, 64, align::yes&gt; little_int64_t;
// 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, uint32_t, 32, align::yes&gt; little_uint32_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>
<hr>
<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>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>

View File

@@ -200,128 +200,128 @@ enum class align {no, yes}; </pre>
class endian_buffer;
</pre>
</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>
<blockquote>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="49%">
<tr>
<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>Sign</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>
<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>
<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">signed</td>
<td width="15%">16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
<td width="15%">8,16,32,64</td>
</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="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%">16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
<td width="15%">8,16,32,64</td>
</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="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>
<td width="49%" align="center"><code>yes</code></td>
</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>
<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">signed</td>
<td width="15%">16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
<td width="15%">8,16,32,64</td>
</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="49%" align="center"><code>yes</code></td>
<td width="10%" align="center"><code>little</code></td>
<td width="10%" align="center">unsigned</td>
<td width="15%">16,32,64</td>
<td width="49%" align="center"><code>yes</code></td>
<td width="15%">8,16,32,64</td>
</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="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>
</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">signed</td>
<td width="15%">32,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>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>
</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">signed</td>
<td width="15%">32,64</td>
<td width="49%" align="center"><code>no</code></td>
</tr>
</table>
</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
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
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
example:</p>
<blockquote>
<pre>static_assert(sizeof(containing_struct) == 12, &quot;sizeof(containing_struct) is wrong&quot;); </pre>
</blockquote>
<p><b><i>Note:</i></b> One-byte big and little buffer types
have identical
functionality. They are provided to improve code readability and searchability.</p>
never actually reverse endianness. They are provided to enable generic code, and
to improve code readability and searchability.</p>
<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">
endianness</a>, value type, size, and <a href="#alignment">alignment</a>. The
@@ -655,7 +656,7 @@ any Boost object libraries.</p>
</ul>
<hr>
<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>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>

View File

@@ -118,7 +118,7 @@ the least-significant byte first, while SPARC CPUs place the most-significant
byte first. Some CPUs, such as the PowerPC, allow the operating system to
choose which ordering applies.</p>
<p><a name="definition"></a>Most-significant-byte-first ordering is traditionally called &quot;big endian&quot;
ordering and the least-significant-byte-first is traditionally called
ordering and least-significant-byte-first is traditionally called
&quot;little-endian&quot; ordering. The names are derived from
<a href="http://en.wikipedia.org/wiki/Jonathan_Swift" title="Jonathan Swift">
Jonathan Swift</a>'s satirical novel <i>
@@ -135,7 +135,7 @@ And programmers may also want to use the library when minimizing either internal
external data sizes is advantageous.</p>
<h2><a name="Introduction">Introduction</a> to the Boost.Endian library</h2>
<p>The Boost.Endian library provides three different approaches to dealing with
<p>Boost.Endian provides three different approaches to dealing with
endianness. All three approaches support integers, floating point types
except&nbsp; <code>long double</code>, and user-define types (UDTs).</p>
@@ -154,15 +154,22 @@ conditional variants.</p>
<p><b><a href="buffers.html">Endian buffer types</a> -</b> The application uses the provided endian
buffer types
to hold values, and explicitly converts to and from the built-in integer and
floating point types to perform arithmetic. Buffer lengths of 1 through 8 bytes
are supported, rather than just 2, 4, and 8 bytes. The types may be aligned or
unaligned.</p>
floating point types. Buffer sizes of 8, 16, 24, 32, 40, 48, 56, and 64 bits (i.e.
1, 2, 3, 4, 5, 6, 7, and 8 bytes) are provided. Unaligned integer buffer types
are provided for all sizes, unaligned floating point buffer types are provided
for 32 and 64 bit sizes, and aligned buffer types are provided for 16, 32, and
64-bit sizes. The provided specific types are typedefs for a generic class
template that may be used directly for less common use cases.</p>
<p><b><a href="arithmetic.html">Endian arithmetic types</a> -</b> The application uses the provided endian
arithmetic types, which supply the same operations as the built-in C++
arithmetic types. All conversions are implicit. Arithmetic integer types with
lengths of 1 through 8 bytes are supported, rather than just 2, 4, and 8 byte
integers. The types may be aligned.</p>
<p><b><a href="arithmetic.html">Endian arithmetic types</a> -</b> The
application uses the provided endian arithmetic types, which supply the same
operations as the built-in C++ arithmetic types. All conversions are implicit.
Arithmetic sizes of 8, 16, 24, 32, 40, 48, 56, and 64 bits (i.e. 1, 2, 3, 4, 5,
6, 7, and 8 bytes) are provided. Unaligned integer types are provided for all
sizes, unaligned floating point types are provided for 32 and 64 bit sizes, and aligned
arithmetic types are provided for 16, 32, and 64-bit sizes. The provided
specific types are typedefs for a generic class template that may be used
directly for less common use cases.</p>
</blockquote>
@@ -178,15 +185,16 @@ Choosing the Approach</a> page. </p>
<h2>Built-in support for <a name="Intrinsic">Intrinsic</a>s</h2>
<p>Most compilers, including GCC, Clang, and Visual C++, supply built-in support for byte swapping intrinsics.
The Endian library uses these intrinsics when available since they may result in smaller and faster generated code, particularly for release
The Endian library uses these intrinsics when available since they may result in smaller and faster generated code, particularly for
optimized
builds.</p>
<p>Defining the macro <code>BOOST_ENDIAN_NO_INTRINSICS</code> will suppress use
of the intrinsics. Useful when intrinsic headers such as
<code>byteswap.h </code>are not being found by your compiler, perhaps because it
of the intrinsics. This is useful when a compiler has no intrinsic support or
fails to locate the appropriate header, perhaps because it
is an older release or has very limited supporting libraries.</p>
<p>The macro <code>BOOST_ENDIAN_INTRINSIC_MSG</code> is defined as
either <code>&quot;no byte swap intrinsics&quot;</code> or a string describing the
particular set of intrinsics being used. Useful for eliminating missing
particular set of intrinsics being used. This is useful for eliminating missing
intrinsics as a source of performance issues.</p>
<h2><a name="Performance">Performance</a></h2>
@@ -385,8 +393,10 @@ setup.</p>
<p><b>Does endianness have any uses outside of portable binary file or network
I/O formats?</b> </p>
<blockquote>
<p>Using the unaligned integer types to save internal or external
memory space is a minor secondary use.</p>
<p>Using the unaligned integer types with a size tailored to the application&#39;s
needs is a minor secondary use that saves internal or external memory space. For
example, using <code>big_int40_buf_ut</code> or <code>big_int40_ut</code> in a
large array saves a lot of space compared to one of the 64-bit types.</p>
</blockquote>
<p><b>Why bother with binary I/O? Why not just use C++ Standard Library stream
inserters and extractors?</b></p>
@@ -583,7 +593,7 @@ Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen and
Vitaly Budovsk. Apologies if anyone has been missed.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->09 February, 2015<!--webbot bot="Timestamp" endspan i-checksum="40544" --></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, 2011, 2013</p>
<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>

View File

@@ -8,8 +8,8 @@ body
}
ins {background-color: #CCFFCC;}
del {background-color: #FFCACA;}
pre {background-color: #D7EEFF; font-size: 95%; font-family: courier, serif;}
code {font-size: 110%; font-family: courier, serif;}
pre {background-color: #D7EEFF; font-size: 95%; font-family: "courier new", courier, serif;}
code {font-size: 110%; font-family: "courier new", courier, serif;}
table {font-size: 100%;}
/*