</li>
<li><a href="#changelog">Revision History</a>
<ul class="sectlevel2">
+<li><a href="#overview_changes_in_1_72_0">Changes in 1.72.0</a></li>
<li><a href="#overview_changes_in_1_71_0">Changes in 1.71.0</a></li>
</ul>
</li>
<h2 id="changelog">Revision History</h2>
<div class="sectionbody">
<div class="sect2">
+<h3 id="overview_changes_in_1_72_0">Changes in 1.72.0</h3>
+<div class="ulist">
+<ul>
+<li>
+<p>Made <code>endian_reverse</code>, <code>conditional_reverse</code> and <code>*_to_*</code> <code>constexpr</code>
+on GCC and Clang</p>
+</li>
+<li>
+<p>Added convenience load and store functions</p>
+</li>
+<li>
+<p>Added floating point convenience typedefs</p>
+</li>
+<li>
+<p>Added a non-const overload of <code>data()</code>; changed its return type to <code>unsigned char*</code></p>
+</li>
+<li>
+<p>Added <code>__int128</code> support to <code>endian_reverse</code> when available</p>
+</li>
+<li>
+<p>Added a convenience header <code>boost/endian.hpp</code></p>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect2">
<h3 id="overview_changes_in_1_71_0">Changes in 1.71.0</h3>
<div class="ulist">
<ul>
little = <code>see below</code>,
};
+ // Byte reversal functions
+
template <class Endian>
Endian endian_reverse(Endian x) noexcept;
EndianReversible conditional_reverse(EndianReversible x,
order order1, order order2) noexcept;
+ // In-place byte reversal functions
+
template <class EndianReversible>
void endian_reverse_inplace(EndianReversible& x) noexcept;
void conditional_reverse_inplace(EndianReversibleInplace& x,
order order1, order order2) noexcept;
+ // Generic load and store functions
+
template<class T, std::size_t N, order Order>
T endian_load( unsigned char const * p ) noexcept;
template<class T, std::size_t N, order Order>
void endian_store( unsigned char * p, T const & v ) noexcept;
+ // Convenience load functions
+
+ boost::int16_t load_little_s16( unsigned char const * p ) noexcept;
+ boost::uint16_t load_little_u16( unsigned char const * p ) noexcept;
+ boost::int16_t load_big_s16( unsigned char const * p ) noexcept;
+ boost::uint16_t load_big_u16( unsigned char const * p ) noexcept;
+
+ boost::int32_t load_little_s24( unsigned char const * p ) noexcept;
+ boost::uint32_t load_little_u24( unsigned char const * p ) noexcept;
+ boost::int32_t load_big_s24( unsigned char const * p ) noexcept;
+ boost::uint32_t load_big_u24( unsigned char const * p ) noexcept;
+
+ boost::int32_t load_little_s32( unsigned char const * p ) noexcept;
+ boost::uint32_t load_little_u32( unsigned char const * p ) noexcept;
+ boost::int32_t load_big_s32( unsigned char const * p ) noexcept;
+ boost::uint32_t load_big_u32( unsigned char const * p ) noexcept;
+
+ boost::int64_t load_little_s40( unsigned char const * p ) noexcept;
+ boost::uint64_t load_little_u40( unsigned char const * p ) noexcept;
+ boost::int64_t load_big_s40( unsigned char const * p ) noexcept;
+ boost::uint64_t load_big_u40( unsigned char const * p ) noexcept;
+
+ boost::int64_t load_little_s48( unsigned char const * p ) noexcept;
+ boost::uint64_t load_little_u48( unsigned char const * p ) noexcept;
+ boost::int64_t load_big_s48( unsigned char const * p ) noexcept;
+ boost::uint64_t load_big_u48( unsigned char const * p ) noexcept;
+
+ boost::int64_t load_little_s56( unsigned char const * p ) noexcept;
+ boost::uint64_t load_little_u56( unsigned char const * p ) noexcept;
+ boost::int64_t load_big_s56( unsigned char const * p ) noexcept;
+ boost::uint64_t load_big_u56( unsigned char const * p ) noexcept;
+
+ boost::int64_t load_little_s64( unsigned char const * p ) noexcept;
+ boost::uint64_t load_little_u64( unsigned char const * p ) noexcept;
+ boost::int64_t load_big_s64( unsigned char const * p ) noexcept;
+ boost::uint64_t load_big_u64( unsigned char const * p ) noexcept;
+
+ // Convenience store functions
+
+ void store_little_s16( unsigned char * p, boost::int16_t v ) noexcept;
+ void store_little_u16( unsigned char * p, boost::uint16_t v ) noexcept;
+ void store_big_s16( unsigned char * p, boost::int16_t v ) noexcept;
+ void store_big_u16( unsigned char * p, boost::uint16_t v ) noexcept;
+
+ void store_little_s24( unsigned char * p, boost::int32_t v ) noexcept;
+ void store_little_u24( unsigned char * p, boost::uint32_t v ) noexcept;
+ void store_big_s24( unsigned char * p, boost::int32_t v ) noexcept;
+ void store_big_u24( unsigned char * p, boost::uint32_t v ) noexcept;
+
+ void store_little_s32( unsigned char * p, boost::int32_t v ) noexcept;
+ void store_little_u32( unsigned char * p, boost::uint32_t v ) noexcept;
+ void store_big_s32( unsigned char * p, boost::int32_t v ) noexcept;
+ void store_big_u32( unsigned char * p, boost::uint32_t v ) noexcept;
+
+ void store_little_s40( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_little_u40( unsigned char * p, boost::uint64_t v ) noexcept;
+ void store_big_s40( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_big_u40( unsigned char * p, boost::uint64_t v ) noexcept;
+
+ void store_little_s48( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_little_u48( unsigned char * p, boost::uint64_t v ) noexcept;
+ void store_big_s48( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_big_u48( unsigned char * p, boost::uint64_t v ) noexcept;
+
+ void store_little_s56( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_little_u56( unsigned char * p, boost::uint64_t v ) noexcept;
+ void store_big_s56( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_big_u56( unsigned char * p, boost::uint64_t v ) noexcept;
+
+ void store_little_s64( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_little_u64( unsigned char * p, boost::uint64_t v ) noexcept;
+ void store_big_s64( unsigned char * p, boost::int64_t v ) noexcept;
+ void store_big_u64( unsigned char * p, boost::uint64_t v ) noexcept;
+
} // namespace endian
} // namespace boost</code></pre>
</div>
</div>
</div>
<div class="sect3">
-<h4 id="conversion_functions">Functions</h4>
+<h4 id="conversion_byte_reversal_functions">Byte Reversal Functions</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>template <class Endian>
</li>
</ul>
</div>
+</div>
+<div class="sect3">
+<h4 id="conversion_in_place_byte_reversal_functions">In-place Byte Reversal Functions</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>template <class EndianReversible>
</li>
</ul>
</div>
+</div>
+<div class="sect3">
+<h4 id="conversion_generic_load_and_store_functions">Generic Load and Store Functions</h4>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code>template<class T, std::size_t N, order Order>
</ul>
</div>
</div>
+<div class="sect3">
+<h4 id="conversion_convenience_load_functions">Convenience Load Functions</h4>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline boost::intM_t load_little_sN( unsigned char const * p ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Reads an N-bit signed little-endian integer from <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Returns</dt>
+<dd>
+<p><code>endian_load<boost::intM_t, N/8, order::little>( p )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline boost::uintM_t load_little_uN( unsigned char const * p ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Reads an N-bit unsigned little-endian integer from <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Returns</dt>
+<dd>
+<p><code>endian_load<boost::uintM_t, N/8, order::little>( p )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline boost::intM_t load_big_sN( unsigned char const * p ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Reads an N-bit signed big-endian integer from <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Returns</dt>
+<dd>
+<p><code>endian_load<boost::intM_t, N/8, order::big>( p )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline boost::uintM_t load_big_uN( unsigned char const * p ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Reads an N-bit unsigned big-endian integer from <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Returns</dt>
+<dd>
+<p><code>endian_load<boost::uintM_t, N/8, order::big>( p )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+</div>
+<div class="sect3">
+<h4 id="conversion_convenience_store_functions">Convenience Store Functions</h4>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline void store_little_sN( unsigned char * p, boost::intM_t v ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Writes an N-bit signed little-endian integer to <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Effects</dt>
+<dd>
+<p><code>endian_store<boost::intM_t, N/8, order::little>( p, v )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline void store_little_uN( unsigned char * p, boost::uintM_t v ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Writes an N-bit unsigned little-endian integer to <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Effects</dt>
+<dd>
+<p><code>endian_store<boost::uintM_t, N/8, order::little>( p, v )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline void store_big_sN( unsigned char * p, boost::intM_t v ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Writes an N-bit signed big-endian integer to <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Effects</dt>
+<dd>
+<p><code>endian_store<boost::intM_t, N/8, order::big>( p, v )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>inline void store_big_uN( unsigned char * p, boost::uintM_t v ) noexcept;</code></pre>
+</div>
+</div>
+<div class="ulist none">
+<ul class="none">
+<li>
+<p></p>
+<div class="paragraph">
+<p>Writes an N-bit unsigned big-endian integer to <code>p</code>.</p>
+</div>
+<div class="dlist">
+<dl>
+<dt class="hdlist1">Effects</dt>
+<dd>
+<p><code>endian_store<boost::uintM_t, N/8, order::big>( p, v )</code>.</p>
+</dd>
+</dl>
+</div>
+</li>
+</ul>
+</div>
+</div>
</div>
<div class="sect2">
<h3 id="conversion_faq">FAQ</h3>
// Low-level I/O such as POSIX read/write or <cstdio>
// fread/fwrite is sometimes used for binary file operations
// when ultimate efficiency is important. Such I/O is often
- // performed in some {cpp} wrapper class, but to drive home the
+ // performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly
// low-level code that does bulk I/O operations, <cstdio>
// fopen/fwrite is used for I/O in this example.
explicit endian_buffer(T v) noexcept;
endian_buffer& operator=(T v) noexcept;
- value_type value() const noexcept;
- const char* data() const noexcept;
+ value_type value() const noexcept;
+ unsigned char* data() noexcept;
+ unsigned char const* data() const noexcept;
private:
- unsigned char value_[ Nbits / CHAR_BIT]; // exposition only
+ unsigned char value_[Nbits / CHAR_BIT]; // exposition only
};
// stream inserter
typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t;
+ // unaligned big endian floating point buffers
+ typedef endian_buffer<order::big, float, 32> big_float32_buf_t;
+ typedef endian_buffer<order::big, double, 64> big_float64_buf_t;
+
// unaligned little endian signed integer buffers
typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t;
typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
+ // unaligned little endian floating point buffers
+ typedef endian_buffer<order::little, float, 32> little_float32_buf_t;
+ typedef endian_buffer<order::little, double, 64> little_float64_buf_t;
+
// unaligned native endian signed integer types
typedef implementation-defined_int8_buf_t native_int8_buf_t;
typedef implementation-defined_int16_buf_t native_int16_buf_t;
typedef implementation-defined_uint56_buf_t native_uint56_buf_t;
typedef implementation-defined_uint64_buf_t native_uint64_buf_t;
+ // unaligned native endian floating point types
+ typedef implementation-defined_float32_buf_t native_float32_buf_t;
+ typedef implementation-defined_float64_buf_t native_float64_buf_t;
+
// aligned big endian signed integer buffers
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at;
+ // aligned big endian floating point buffers
+ typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at;
+ typedef endian_buffer<order::big, double, 64, align::yes> big_float64_buf_at;
+
// aligned little endian signed integer buffers
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at;
+ // aligned little endian floating point buffers
+ typedef endian_buffer<order::little, float, 32, align::yes> little_float32_buf_at;
+ typedef endian_buffer<order::little, double, 64, align::yes> little_float64_buf_at;
+
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
</div>
<div class="listingblock">
<div class="content">
-<pre class="highlight"><code>const char* data() const noexcept;</code></pre>
+<pre class="highlight"><code>unsigned char* data() noexcept;</code></pre>
+</div>
+</div>
+<div class="listingblock">
+<div class="content">
+<pre class="highlight"><code>unsigned char const* data() const noexcept;</code></pre>
</div>
</div>
<div class="ulist none">
endian_arithmetic& operator=(T v) noexcept;
operator value_type() const noexcept;
value_type value() const noexcept; // for exposition; see endian_buffer
- const char* data() const noexcept; // for exposition; see endian_buffer
+ unsigned char* data() noexcept; // for exposition; see endian_buffer
+ unsigned char const* data() const noexcept; // for exposition; see endian_buffer
// arithmetic operations
// note that additional operations are provided by the value_type
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_t;
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_t;
+ // unaligned big endian floating point types
+ typedef endian_arithmetic<order::big, float, 32> big_float32_t;
+ typedef endian_arithmetic<order::big, double, 64> big_float64_t;
+
// unaligned little endian signed integer types
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_t;
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_t;
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
+ // unaligned little endian floating point types
+ typedef endian_arithmetic<order::little, float, 32> little_float32_t;
+ typedef endian_arithmetic<order::little, double, 64> little_float64_t;
+
// unaligned native endian signed integer types
typedef implementation-defined_int8_t native_int8_t;
typedef implementation-defined_int16_t native_int16_t;
typedef implementation-defined_uint56_t native_uint56_t;
typedef implementation-defined_uint64_t native_uint64_t;
+ // unaligned native endian floating point types
+ typedef implementation-defined_float32_t native_float32_t;
+ typedef implementation-defined_float64_t native_float64_t;
+
// aligned big endian signed integer types
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_at;
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_at;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_at;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_at;
+ // aligned big endian floating point types
+ typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_at;
+ typedef endian_arithmetic<order::big, double, 64, align::yes> big_float64_at;
+
// aligned little endian signed integer types
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_at;
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_at;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_at;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_at;
+ // aligned little endian floating point types
+ typedef endian_arithmetic<order::little, float, 32, align::yes> little_float32_at;
+ typedef endian_arithmetic<order::little, double, 64, align::yes> little_float64_at;
+
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for that use case
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2019-08-14 12:02:29 UTC
+Last updated 2019-12-10 00:18:50 UTC
</div>
</div>
<style>
+
*:not(pre)>code { background: none; color: #600000; }
+:not(pre):not([class^=L])>code { background: none; color: #600000; }
table tr.even, table tr.alt, table tr:nth-of-type(even) { background: none; }
+
</style>
</body>
</html>
\ No newline at end of file