mirror of
https://github.com/boostorg/endian.git
synced 2025-07-31 13:07:24 +02:00
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:
@@ -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">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"><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>_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">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"><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>_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, "sizeof(containing_struct) is wrong"); </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<order::little, double, 64, align::no> little_float64_ut;
|
||||
|
||||
// aligned big endian signed integer types
|
||||
typedef endian<order::big, int8_t, 8, align::yes> big_int8_t;
|
||||
typedef endian<order::big, int16_t, 16, align::yes> big_int16_t;
|
||||
typedef endian<order::big, int32_t, 32, align::yes> big_int32_t;
|
||||
typedef endian<order::big, int64_t, 64, align::yes> big_int64_t;
|
||||
|
||||
// aligned big endian unsigned integer types
|
||||
typedef endian<order::big, uint8_t, 8, align::yes> big_uint8_t;
|
||||
typedef endian<order::big, uint16_t, 16, align::yes> big_uint16_t;
|
||||
typedef endian<order::big, uint32_t, 32, align::yes> big_uint32_t;
|
||||
typedef endian<order::big, uint64_t, 64, align::yes> big_uint64_t;
|
||||
|
||||
// aligned little endian signed integer types
|
||||
typedef endian<order::little, int8_t, 8, align::yes> little_int8_t;
|
||||
typedef endian<order::little, int16_t, 16, align::yes> little_int16_t;
|
||||
typedef endian<order::little, int32_t, 32, align::yes> little_int32_t;
|
||||
typedef endian<order::little, int64_t, 64, align::yes> little_int64_t;
|
||||
|
||||
// aligned little endian unsigned integer types
|
||||
typedef endian<order::little, uint8_t, 8, align::yes> little_uint8_t;
|
||||
typedef endian<order::little, uint16_t, 16, align::yes> little_uint16_t;
|
||||
typedef endian<order::little, uint32_t, 32, align::yes> little_uint32_t;
|
||||
typedef endian<order::little, uint64_t, 64, align::yes> 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>
|
||||
|
155
doc/buffers.html
155
doc/buffers.html
@@ -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="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, "sizeof(containing_struct) is wrong"); </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>
|
||||
|
@@ -96,21 +96,25 @@ namespace endian
|
||||
typedef endian_arithmetic<order::little, double, 64, align::no> little_float64_ut;
|
||||
|
||||
// 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, int32_t, 32, align::yes> big_int32_t;
|
||||
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_t;
|
||||
|
||||
// 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, uint32_t, 32, align::yes> big_uint32_t;
|
||||
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_t;
|
||||
|
||||
// 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, int32_t, 32, align::yes> little_int32_t;
|
||||
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_t;
|
||||
|
||||
// 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, uint32_t, 32, align::yes> little_uint32_t;
|
||||
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_t;
|
||||
|
@@ -93,21 +93,25 @@ namespace endian
|
||||
typedef endian_buffer<order::little, double, 64, align::no> little_float64_buf_ut;
|
||||
|
||||
// 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, int32_t, 32, align::yes> big_int32_buf_t;
|
||||
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_t;
|
||||
|
||||
// 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, uint32_t, 32, align::yes> big_uint32_buf_t;
|
||||
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_t;
|
||||
|
||||
// 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, int32_t, 32, align::yes> little_int32_buf_t;
|
||||
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_t;
|
||||
|
||||
// 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, uint32_t, 32, align::yes> little_uint32_buf_t;
|
||||
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_t;
|
||||
|
@@ -98,18 +98,22 @@ namespace
|
||||
BOOST_TEST_EQ(sizeof(native_uint56_buf_ut), 7u);
|
||||
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_int32_buf_t), 4u);
|
||||
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_uint32_buf_t), 4u);
|
||||
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_int32_buf_t), 4u);
|
||||
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_uint32_buf_t), 4u);
|
||||
BOOST_TEST_EQ(sizeof(little_uint64_buf_t), 8u);
|
||||
|
@@ -402,19 +402,23 @@ namespace
|
||||
VERIFY_SIZE( sizeof( native_uint56_ut ), 7 );
|
||||
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_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_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_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_uint64_t ), 8 );
|
||||
} // check_size
|
||||
|
Reference in New Issue
Block a user