forked from boostorg/endian
Decompose Reversible into EndianReversible and EndianReversibleInplace.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
|
||||
|
||||
<head>
|
||||
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
|
||||
@@ -45,7 +45,7 @@
|
||||
<a href="#Reference">Reference</a><br>
|
||||
<a href="#Synopsis">Synopsis</a><br>
|
||||
<a href="#Requirements">Requirements</a><br>
|
||||
<code><a href="#Reversible">Reversible</a></code><br>
|
||||
<code><a href="#EndianReversible">EndianReversible</a></code><br>
|
||||
<a href="#Customization-points">Customization for
|
||||
UDTs</a><br>
|
||||
<a href="#Functions">Functions</a><br>
|
||||
@@ -98,6 +98,7 @@ namespace endian
|
||||
native = <b><i>implementation-defined-as-big-or-little
|
||||
</i></b>};
|
||||
|
||||
<span style="background-color: #FFFF00">TODO</span><span style="background-color: #FFFF00">: Add overloads for char, </span><span style="background-color: #FFFF00">wchar_t</span><span style="background-color: #FFFF00">, char16_t, char32_t</span>
|
||||
int8_t <a href="#endian_reverse">endian_reverse</a>(int8_t x) noexcept;
|
||||
int16_t <a href="#endian_reverse">endian_reverse</a>(int16_t x) noexcept;
|
||||
int32_t <a href="#endian_reverse">endian_reverse</a>(int32_t x) noexcept;
|
||||
@@ -109,35 +110,35 @@ namespace endian
|
||||
float <a href="#endian_reverse">endian_reverse</a>(float x) noexcept;
|
||||
double <a href="#endian_reverse">endian_reverse</a>(double x) noexcept;
|
||||
|
||||
template <class Reversible>
|
||||
Reversible big_to_native(Reversible x) noexcept;
|
||||
template <class Reversible>
|
||||
Reversible native_to_big(Reversible x) noexcept;
|
||||
template <class Reversible>
|
||||
Reversible little_to_native(Reversible x) noexcept;
|
||||
template <class Reversible>
|
||||
Reversible native_to_little(Reversible x) noexcept;
|
||||
template <order O1, order O2, class Reversible>
|
||||
Reversible conditional_reverse(Reversible x) noexcept;
|
||||
template <class Reversible>
|
||||
Reversible conditional_reverse(Reversible x,
|
||||
template <class EndianReversible>
|
||||
EndianReversible big_to_native(EndianReversible x) noexcept;
|
||||
template <class EndianReversible>
|
||||
EndianReversible native_to_big(EndianReversible x) noexcept;
|
||||
template <class EndianReversible>
|
||||
EndianReversible little_to_native(EndianReversible x) noexcept;
|
||||
template <class EndianReversible>
|
||||
EndianReversible native_to_little(EndianReversible x) noexcept;
|
||||
template <order O1, order O2, class EndianReversible>
|
||||
EndianReversible conditional_reverse(EndianReversible x) noexcept;
|
||||
template <class EndianReversible>
|
||||
EndianReversible conditional_reverse(EndianReversible x,
|
||||
order order1, order order2) noexcept;
|
||||
|
||||
template <class Reversible>
|
||||
void endian_reverse_inplace(Reversible& x) noexcept;
|
||||
template <class EndianReversible>
|
||||
void endian_reverse_inplace(EndianReversible& x) noexcept;
|
||||
|
||||
template <class Reversible>
|
||||
void big_to_native_inplace(Reversible& x) noexcept;
|
||||
template <class Reversible>
|
||||
void native_to_big_inplace(Reversible& x) noexcept;
|
||||
template <class Reversible>
|
||||
void little_to_native_inplace(Reversible& x) noexcept;
|
||||
template <class Reversible>
|
||||
void native_to_little_inplace(Reversible& x) noexcept;
|
||||
template <order O1, order O2, class Reversible>
|
||||
void conditional_reverse_inplace(Reversible& x) noexcept;
|
||||
template <class Reversible>
|
||||
void conditional_reverse_inplace(Reversible& x,
|
||||
template <class EndianReversibleInplace>
|
||||
void big_to_native_inplace(EndianReversibleInplace& x) noexcept;
|
||||
template <class EndianReversibleInplace>
|
||||
void native_to_big_inplace(EndianReversibleInplace& x) noexcept;
|
||||
template <class EndianReversibleInplace>
|
||||
void little_to_native_inplace(EndianReversibleInplace& x) noexcept;
|
||||
template <class EndianReversibleInplace>
|
||||
void native_to_little_inplace(EndianReversibleInplace& x) noexcept;
|
||||
template <order O1, order O2, class EndianReversibleInplace>
|
||||
void conditional_reverse_inplace(EndianReversibleInplace& x) noexcept;
|
||||
template <class EndianReversibleInplace>
|
||||
void conditional_reverse_inplace(EndianReversibleInplace& x,
|
||||
order order1, order order2) noexcept;
|
||||
|
||||
} // namespace endian
|
||||
@@ -146,77 +147,91 @@ namespace endian
|
||||
constant <code>native</code> as
|
||||
<code>big</code> on big endian platforms and <code>little</code> on little
|
||||
endian platforms.</p>
|
||||
<h3 dir="ltr"><a name="Definitions">Definitions</a></h3>
|
||||
<p dir="ltr">The standard integral types (C++std 3.9.1) except <code>bool</code>,
|
||||
and the floating point types <code>float</code> and <code>double</code> are
|
||||
collectively called the <i>endian types</i>.</p>
|
||||
<h3><a name="Requirements">Requirements</a></h3>
|
||||
<h4>Template argument <code><a name="Reversible">Reversible</a></code> requirements</h4>
|
||||
<p>This subsection describes names that are used to specify constraints on
|
||||
template arguments.</p>
|
||||
<p>User-defined types may be used in the function templates in this header only
|
||||
if they meet these requirements.</p>
|
||||
<p><code>Reversible</code> is an object type to be supplied by a C++ program
|
||||
instantiating a template.</p>
|
||||
<h4><a name="Template-argument-requirements">Template argument requirements</a></h4>
|
||||
<p dir="ltr">The template definitions in the <code>boost/endian/conversion.hpp</code>
|
||||
header refer to various named requirements whose details are set out in the
|
||||
tables in this subsection. In these tables, <code>T</code> is an object or
|
||||
reference type to be supplied by a C++ program instantiating a template; <code>x</code>
|
||||
is a value of type (possibly <code>const</code>) <code>T</code>; <code>mlx</code> is a
|
||||
modifiable lvalue of type <code>T</code>.</p>
|
||||
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td width="160"><b>Expression</b></td>
|
||||
<td width="160"><b>Meaning of x</b></td>
|
||||
<td width="347"><b>Requirements</b></td>
|
||||
<td colspan="3" align="center"><b><code><a name="EndianReversible">EndianReversible</a></code></b>
|
||||
requirements (in addition to <b><code>CopyConstructible</code></b>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<p><code>endian_reverse(x)</code></td>
|
||||
<td valign="top">
|
||||
<code>x</code> is a value of a possibly <code>const</code> type convertible
|
||||
to <code>Reversible</code>.</td>
|
||||
<td>
|
||||
<p>Returns the value of <code>x</code> with the
|
||||
order of its constituent bytes reversed.</td>
|
||||
<td><b>Expression</b></td>
|
||||
<td><b>Return<br>
|
||||
type</b></td>
|
||||
<td><b>Requirements</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<code>endian_reverse_inplace(x)</code></td>
|
||||
<td valign="top">
|
||||
<code>x</code> is a
|
||||
modifiable lvalue of type <code>Reversible</code>.</td>
|
||||
<td>
|
||||
The order of the constituent bytes of <code>x</code> are
|
||||
reversed.</td>
|
||||
<td valign="top"><code>endian_reverse(x)</code></td>
|
||||
<td align="center" valign="top"><code>T</code></td>
|
||||
<td> <code>T</code> is an endian type or a class type.<p>If <code>T</code> is
|
||||
an endian type, returns the value of <code>x</code> with the order of bytes
|
||||
reversed.</p>
|
||||
<p>If <code>T</code> is an class type, the function:</p>
|
||||
<ul>
|
||||
<li>Returns the value of <code>x</code>
|
||||
with the order of bytes reversed for all data members of types or arrays of
|
||||
types that meet the <code>EndianReversible</code> requirements, and;</li>
|
||||
<li>Is a non-member function in the same namespace as <code>T</code> that
|
||||
can be found by argument dependent lookup (ADL). </li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p> </p>
|
||||
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||
<tr>
|
||||
<td colspan="2" align="center"><b><code><a name="EndianReversibleInplace">EndianReversibleInplace</a></code></b>
|
||||
requirements (in addition to <b><code>CopyConstructible</code></b>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Expression</b></td>
|
||||
<td><b>Requirements</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><code>endian_reverse_inplace(mlx)</code></td>
|
||||
<td> <code>T</code> is an endian type or a class type.<p>If <code>T</code> is
|
||||
an endian type, reverses the order of bytes in <code>mlx</code>.</p>
|
||||
<p>If <code>T</code> is an class type, the function:</p>
|
||||
<ul>
|
||||
<li>Reverses the order of bytes of all data members of <code>mlx</code>
|
||||
that have types or arrays of
|
||||
types that meet the <code>EndianReversible</code> or <code>EndianReversibleInplace</code>
|
||||
requirements, and;</li>
|
||||
<li>Is a non-member function in the same namespace as <code>T</code> that
|
||||
can be found by argument dependent lookup (ADL). </li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<blockquote>
|
||||
|
||||
<p> [<i>Note:</i> A user-defined type meets these requirements by defining a
|
||||
non-member function in the same namespace as the UDT itself so that the function
|
||||
can be found by argument dependent lookup (ADL). <i>—end note</i>]</p>
|
||||
|
||||
<p> [<i>Note:</i> Because there is a function template for <code>endian_reverse_inplace</code>
|
||||
that calls <code>endian_reverse</code>, only <code>endian_reverse</code>
|
||||
is required for a user-defined type to meet the <code>Reversible</code>
|
||||
requirements. User-defined types may provide <code>endian_reverse_inplace</code>
|
||||
for improved efficiency. <i>—end note</i>]</p>
|
||||
|
||||
<p> <span style="background-color: #FFFF00">This still isn't right. There are
|
||||
really separate Reversible and </span><span style="background-color: #FFFF00">
|
||||
ReversibleHere</span><span style="background-color: #FFFF00"> requirements, and
|
||||
the </span><span style="background-color: #FFFF00">endian_reverse_here</span><span style="background-color: #FFFF00">
|
||||
template's type should be Reversible. See the udt_conversion_example for a type
|
||||
that is ReversibleHere but not Reversible and works just fine.</span></p>
|
||||
|
||||
</blockquote>
|
||||
is required for a user-defined type to meet the <code>EndianReversibleInplace</code>
|
||||
requirements. Although User-defined types are not required to supply an <code>endian_reverse_inplace</code>
|
||||
function, doing so may improved efficiency. <i> —end note</i>]</p>
|
||||
|
||||
<h4> <a name="Customization-points">Customization points</a> for user-defined types (<a name="UDT">UDT</a>s)</h4>
|
||||
|
||||
<p> This subsection describes requirements on the endian library's own
|
||||
implementation.</p>
|
||||
<p> This subsection describes requirements on the Endian library's implementation.</p>
|
||||
|
||||
<p> The endianness reversal function templates that return values are
|
||||
<p> The library's function templates requiring <code>
|
||||
<a href="#EndianReversible">EndianReversible</a></code> are
|
||||
required to perform reversal of endianness if needed by making an unqualified
|
||||
call to <code>endian_reverse(<i>argument</i>)</code>, as described in the
|
||||
preceding table.</p>
|
||||
call to <code>endian_reverse()</code>.</p>
|
||||
|
||||
<p> The endianness reversal function templates that modify their argument in
|
||||
place, except <code>endian_reverse_inplace</code> itself, are required to perform reversal of endianness if needed by making an
|
||||
unqualified call to <code>endian_reverse_inplace(<i>argument</i>)</code>,
|
||||
as described in the preceding table.</p>
|
||||
<p> The library's function templates requiring <code>
|
||||
<a href="#EndianReversibleInplace">EndianReversibleInplace</a></code> are required to perform reversal of endianness if needed by making an
|
||||
unqualified call to <code>endian_reverse_inplace()</code>.</p>
|
||||
|
||||
<p> See <a href="../example/udt_conversion_example.cpp">
|
||||
udt_conversion_example.cpp</a> for an example user-defined type.</p>
|
||||
@@ -233,90 +248,93 @@ uint64_t endian_reverse(uint64_t x) noexcept;
|
||||
float endian_reverse(float x) noexcept;
|
||||
double endian_reverse(double x) noexcept;</pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <i><code>x</code></i>, with the order of its
|
||||
<p dir="ltr"><i>Returns:</i> <i><code>x</code></i>, with the order of its
|
||||
constituent bytes reversed.</p>
|
||||
<p><i>Remarks:</i> Meet the <code>EndianReversible</code> requirements.</p>
|
||||
<p>[<i>Note:</i> The Boost.Endian library does not provide overloads for the C++ standard library
|
||||
supplied types. <i>—end note</i>]</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>template <class Reversible>
|
||||
Reversible big_to_native(Reversible x) noexcept;</pre>
|
||||
<pre>template <class EndianReversible>
|
||||
EndianReversible big_to_native(EndianReversible x) noexcept;</pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Returns:</i> <code>conditional_reverse<order::big,
|
||||
order::native>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
Reversible native_to_big(Reversible x) noexcept; </pre>
|
||||
<pre>template <class EndianReversible>
|
||||
EndianReversible native_to_big(EndianReversible x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <code>conditional_reverse<order::native, order::big>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
Reversible little_to_native(Reversible x) noexcept; </pre>
|
||||
<pre>template <class EndianReversible>
|
||||
EndianReversible little_to_native(EndianReversible x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <code>conditional_reverse<order::little, order::native>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
Reversible native_to_little(Reversible x) noexcept; </pre>
|
||||
<pre>template <class EndianReversible>
|
||||
EndianReversible native_to_little(EndianReversible x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <code>conditional_reverse<order::native, order::little>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <order O1, order O2, class Reversible>
|
||||
Reversible conditional_reverse(Reversible x) noexcept; </pre>
|
||||
<pre>template <order O1, order O2, class EndianReversible>
|
||||
EndianReversible conditional_reverse(EndianReversible x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <code>x</code> if <code>O1 == O2,</code> otherwise
|
||||
<code>endian_reverse(x)</code>.</p>
|
||||
<p><i>Remarks: </i>Whether <code>x</code> or <code>endian_reverse(x)</code>
|
||||
is to be returned shall be determined at compile time.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
Reversible conditional_reverse(Reversible x,
|
||||
<pre>template <class EndianReversible>
|
||||
EndianReversible conditional_reverse(EndianReversible x,
|
||||
order order1, order order2) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Returns:</i> <code>order1 == order2 ? x : endian_reverse(x)</code>.</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>template <class Reversible>
|
||||
void endian_reverse_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <class EndianReversible>
|
||||
void endian_reverse_inplace(EndianReversible& x) noexcept; </pre>
|
||||
|
||||
<blockquote>
|
||||
<p><i>Effects:</i> <code>x</code> <code>= endian_reverse(x)</code>.</p>
|
||||
</blockquote>
|
||||
|
||||
<pre>template <class Reversible>
|
||||
void big_to_native_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <class EndianReversibleInplace>
|
||||
void big_to_native_inplace(EndianReversibleInplace& x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Effects:</i> <code>conditional_reverse_inplace<order::big,
|
||||
order::native>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
void native_to_big_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <class EndianReversibleInplace>
|
||||
void native_to_big_inplace(EndianReversibleInplace& x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Effects:</i> <code>conditional_reverse_inplace<order::native,
|
||||
order::big>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
void little_to_native_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <class EndianReversibleInplace>
|
||||
void little_to_native_inplace(EndianReversibleInplace& x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Effects:</i> <code>conditional_reverse_inplace<order::little, order::native>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
void native_to_little_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <class EndianReversibleInplace>
|
||||
void native_to_little_inplace(EndianReversibleInplace& x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p>
|
||||
<i>Effects:</i> <code>conditional_reverse_inplace<order::native,
|
||||
order::little>(x)</code>.</p>
|
||||
</blockquote>
|
||||
<pre>template <order O1, order O2, class Reversible>
|
||||
void conditional_reverse_inplace(Reversible& x) noexcept; </pre>
|
||||
<pre>template <order O1, order O2, class EndianReversibleInplace>
|
||||
void conditional_reverse_inplace(EndianReversibleInplace& x) noexcept; </pre>
|
||||
<blockquote>
|
||||
<p><i>Effects:</i> None if <code>O1 == O2,</code> otherwise
|
||||
<code>endian_reverse_inplace(x)</code>.</p>
|
||||
<p><i>Remarks: </i>Which effect applies shall be determined at compile time.</p>
|
||||
</blockquote>
|
||||
<pre>template <class Reversible>
|
||||
void conditional_reverse_inplace(Reversible& x,
|
||||
<pre>template <class EndianReversibleInplace>
|
||||
void conditional_reverse_inplace(EndianReversibleInplace& x,
|
||||
order order1, order order2) noexcept; </pre>
|
||||
|
||||
|
||||
@@ -348,7 +366,7 @@ Pierre Talbot provided the <code>int8_t endian_reverse()</code> and templated
|
||||
<code>endian_reverse_inplace()</code> implementations.</p>
|
||||
<hr>
|
||||
<p>Last revised:
|
||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->10 December, 2014<!--webbot bot="Timestamp" endspan i-checksum="38633" --></p>
|
||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->11 December, 2014<!--webbot bot="Timestamp" endspan i-checksum="38635" --></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>
|
||||
|
||||
|
@@ -66,33 +66,35 @@ namespace endian
|
||||
inline double endian_reverse(double x) BOOST_NOEXCEPT;
|
||||
|
||||
// reverse byte order unless native endianness is big
|
||||
template <class Reversible >
|
||||
inline Reversible big_to_native(Reversible x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT;
|
||||
// Returns: x if native endian order is big, otherwise endian_reverse(x)
|
||||
template <class Reversible >
|
||||
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT;
|
||||
// Returns: x if native endian order is big, otherwise endian_reverse(x)
|
||||
|
||||
// reverse byte order unless native endianness is little
|
||||
template <class Reversible >
|
||||
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT;
|
||||
// Returns: x if native endian order is little, otherwise endian_reverse(x)
|
||||
template <class Reversible >
|
||||
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT;
|
||||
// Returns: x if native endian order is little, otherwise endian_reverse(x)
|
||||
|
||||
// generic conditional reverse byte order
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
inline Reversible conditional_reverse(Reversible from) BOOST_NOEXCEPT;
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||
class EndianReversible>
|
||||
inline EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
|
||||
// Returns: If From == To have different values, from.
|
||||
// Otherwise endian_reverse(from).
|
||||
// Remarks: The From == To test, and as a consequence which form the return takes, is
|
||||
// is determined at compile time.
|
||||
|
||||
// runtime conditional reverse byte order
|
||||
template <class Reversible >
|
||||
inline Reversible conditional_reverse(Reversible from,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible conditional_reverse(EndianReversible from,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
|
||||
BOOST_NOEXCEPT;
|
||||
// Returns: from_order == to_order ? from : endian_reverse(from).
|
||||
|
||||
//------------------------------------------------------------------------------------//
|
||||
@@ -123,33 +125,33 @@ namespace endian
|
||||
//------------------------------------------------------------------------------------//
|
||||
|
||||
// reverse in place
|
||||
template <class Value>
|
||||
inline void endian_reverse_inplace(Value& x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversible>
|
||||
inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
|
||||
// Effects: x = endian_reverse(x)
|
||||
|
||||
// reverse in place unless native endianness is big
|
||||
template <class Reversible>
|
||||
inline void big_to_native_inplace(Reversible& x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversibleInplace>
|
||||
inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
// Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
|
||||
template <class Reversible>
|
||||
inline void native_to_big_inplace(Reversible& x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversibleInplace>
|
||||
inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
// Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
|
||||
|
||||
// reverse in place unless native endianness is little
|
||||
template <class Reversible>
|
||||
inline void little_to_native_inplace(Reversible& x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversibleInplace>
|
||||
inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
|
||||
template <class Reversible>
|
||||
inline void native_to_little_inplace(Reversible& x) BOOST_NOEXCEPT;
|
||||
template <class EndianReversibleInplace>
|
||||
inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
|
||||
|
||||
// generic conditional reverse in place
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
inline void conditional_reverse_inplace(Reversible& x) BOOST_NOEXCEPT;
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
|
||||
// runtime reverse in place
|
||||
template <class Reversible>
|
||||
inline void conditional_reverse_inplace(Reversible& x,
|
||||
template <class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
|
||||
BOOST_NOEXCEPT;
|
||||
|
||||
@@ -296,8 +298,8 @@ namespace endian
|
||||
return detail::std_endian_reverse(x);
|
||||
}
|
||||
|
||||
template <class Reversible >
|
||||
inline Reversible big_to_native(Reversible x) BOOST_NOEXCEPT
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
return x;
|
||||
@@ -306,8 +308,8 @@ namespace endian
|
||||
# endif
|
||||
}
|
||||
|
||||
template <class Reversible >
|
||||
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
return x;
|
||||
@@ -316,8 +318,8 @@ namespace endian
|
||||
# endif
|
||||
}
|
||||
|
||||
template <class Reversible >
|
||||
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
return x;
|
||||
@@ -326,8 +328,8 @@ namespace endian
|
||||
# endif
|
||||
}
|
||||
|
||||
template <class Reversible >
|
||||
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
return x;
|
||||
@@ -340,7 +342,7 @@ namespace endian
|
||||
{
|
||||
// Primary template and specializations to support endian_reverse().
|
||||
// See rationale in endian_reverse() below.
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
|
||||
class value_converter ; // primary template
|
||||
template <class T> class value_converter <order::big, order::big, T>
|
||||
{public: T operator()(T x) BOOST_NOEXCEPT {return x;}};
|
||||
@@ -353,18 +355,18 @@ namespace endian
|
||||
}
|
||||
|
||||
// generic conditional reverse
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
inline Reversible conditional_reverse(Reversible from) BOOST_NOEXCEPT {
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
|
||||
inline EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT {
|
||||
// work around lack of function template partial specialization by instantiating
|
||||
// a function object of a class that is partially specialized on the two order
|
||||
// template parameters, and then calling its operator().
|
||||
detail::value_converter <From, To, Reversible> tmp;
|
||||
detail::value_converter <From, To, EndianReversible> tmp;
|
||||
return tmp(from);
|
||||
}
|
||||
|
||||
// runtime conditional reverse
|
||||
template <class Reversible >
|
||||
inline Reversible conditional_reverse(Reversible from,
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible conditional_reverse(EndianReversible from,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT
|
||||
{
|
||||
return from_order == to_order ? from : endian_reverse(from);
|
||||
@@ -375,41 +377,41 @@ namespace endian
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// reverse in place
|
||||
template <class Value>
|
||||
inline void endian_reverse_inplace(Value& x) BOOST_NOEXCEPT
|
||||
template <class EndianReversible>
|
||||
inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT
|
||||
{
|
||||
x = endian_reverse(x);
|
||||
}
|
||||
|
||||
template <class Reversible>
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
inline void big_to_native_inplace(Reversible&) BOOST_NOEXCEPT {}
|
||||
inline void big_to_native_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void big_to_native_inplace(Reversible& x) BOOST_NOEXCEPT
|
||||
inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{ endian_reverse_inplace(x); }
|
||||
# endif
|
||||
template <class Reversible>
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
inline void native_to_big_inplace(Reversible&) BOOST_NOEXCEPT {}
|
||||
inline void native_to_big_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void native_to_big_inplace(Reversible& x) BOOST_NOEXCEPT
|
||||
inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{
|
||||
endian_reverse_inplace(x);
|
||||
}
|
||||
# endif
|
||||
|
||||
template <class Reversible>
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
inline void little_to_native_inplace(Reversible&) BOOST_NOEXCEPT {}
|
||||
inline void little_to_native_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void little_to_native_inplace(Reversible& x) BOOST_NOEXCEPT
|
||||
inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{ endian_reverse_inplace(x); }
|
||||
# endif
|
||||
template <class Reversible>
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
inline void native_to_little_inplace(Reversible&) BOOST_NOEXCEPT {}
|
||||
inline void native_to_little_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void native_to_little_inplace(Reversible& x) BOOST_NOEXCEPT
|
||||
inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{
|
||||
endian_reverse_inplace(x);
|
||||
}
|
||||
@@ -420,7 +422,7 @@ namespace endian
|
||||
// Primary template and specializations support generic
|
||||
// endian_reverse_inplace().
|
||||
// See rationale in endian_reverse_inplace() below.
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
|
||||
class converter; // primary template
|
||||
template <class T> class converter<order::big, order::big, T>
|
||||
{public: void operator()(T&) BOOST_NOEXCEPT {/*no effect*/}};
|
||||
@@ -433,19 +435,19 @@ namespace endian
|
||||
} // namespace detail
|
||||
|
||||
// generic conditional reverse in place
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||
inline void conditional_reverse_inplace(Reversible& x) BOOST_NOEXCEPT
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{
|
||||
// work around lack of function template partial specialization by instantiating
|
||||
// a function object of a class that is partially specialized on the two order
|
||||
// template parameters, and then calling its operator().
|
||||
detail::converter<From, To, Reversible> tmp;
|
||||
detail::converter<From, To, EndianReversibleInplace> tmp;
|
||||
tmp(x); // call operator ()
|
||||
}
|
||||
|
||||
// runtime reverse in place
|
||||
template <class Reversible>
|
||||
inline void conditional_reverse_inplace(Reversible& x,
|
||||
template <class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x,
|
||||
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
|
||||
BOOST_NOEXCEPT
|
||||
{
|
||||
|
@@ -90,7 +90,7 @@ struct construct
|
||||
static void test()
|
||||
{
|
||||
T2 o2(1);
|
||||
T1 o1(o2);
|
||||
T1 o1(o2); // TODO: does this make sense for char types?
|
||||
++o1; // quiet gcc unused variable warning
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user