forked from boostorg/endian
Drop the _unless_big and _unless_little functions. KISS. They were confusing, and less confusing names were never found.
This commit is contained in:
@@ -6,11 +6,12 @@ return-by-value modify-argument
|
|||||||
reverse_endianness reverse_endianness_in_place
|
reverse_endianness reverse_endianness_in_place
|
||||||
" reverse_endianness_arg
|
" reverse_endianness_arg
|
||||||
endian_reverse endian_reverse_in_place
|
endian_reverse endian_reverse_in_place
|
||||||
|
" endian_reverse_in_situ
|
||||||
" endian_reverse_here
|
" endian_reverse_here
|
||||||
" endian_reverse_this
|
" endian_reverse_this
|
||||||
" endian_reverse_self
|
" endian_reverse_self
|
||||||
" endian_reverse_arg
|
" endian_reverse_arg
|
||||||
" endian_reverse_in <------
|
" endian_reverse_in
|
||||||
|
|
||||||
reverse reverse_in_place
|
reverse reverse_in_place
|
||||||
reverse_endian reverse_endian_in_place
|
reverse_endian reverse_endian_in_place
|
||||||
@@ -47,6 +48,11 @@ be_to_ne ne_to_be
|
|||||||
|
|
||||||
from_big, to_big, reverse_unless_big
|
from_big, to_big, reverse_unless_big
|
||||||
|
|
||||||
|
big_to_native big_to_native
|
||||||
|
native_to_big native_to_big
|
||||||
|
reverse_unless_native_big ------ <------
|
||||||
|
conditional_reverse reverse_unless_same<...>() <------
|
||||||
|
runtime_conditional_reverse reverse_unless_same() <------
|
||||||
|
|
||||||
merriam-webster.com/dictionary
|
merriam-webster.com/dictionary
|
||||||
|
|
||||||
|
@@ -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>
|
<head>
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
|
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
|
||||||
@@ -75,7 +75,7 @@ ordering. User defined types are also supported.</p>
|
|||||||
|
|
||||||
<h2><a name="Reference">Reference</a></h2>
|
<h2><a name="Reference">Reference</a></h2>
|
||||||
|
|
||||||
<p>Functions are implemented <code>inline</code> if appropriate.<code> noexcept</code> is
|
<p>Functions are implemented if appropriate.<code> noexcept</code> is
|
||||||
elided for compilers that do not support it.
|
elided for compilers that do not support it.
|
||||||
Boost scoped enum emulation is used so that the library still works for compilers that do not support scoped enums. </p>
|
Boost scoped enum emulation is used so that the library still works for compilers that do not support scoped enums. </p>
|
||||||
|
|
||||||
@@ -96,7 +96,6 @@ namespace endian
|
|||||||
native = <b><i>implementation-defined</i></b> // same as order::big or order::little<b><i>
|
native = <b><i>implementation-defined</i></b> // same as order::big or order::little<b><i>
|
||||||
</i></b>};
|
</i></b>};
|
||||||
|
|
||||||
// reverse byte order (i.e. endianness)
|
|
||||||
int8_t <a href="#reverse_endianness">reverse_endianness</a>(int8_t x) noexcept;
|
int8_t <a href="#reverse_endianness">reverse_endianness</a>(int8_t x) noexcept;
|
||||||
int16_t <a href="#reverse_endianness">reverse_endianness</a>(int16_t x) noexcept;
|
int16_t <a href="#reverse_endianness">reverse_endianness</a>(int16_t x) noexcept;
|
||||||
int32_t <a href="#reverse_endianness">reverse_endianness</a>(int32_t x) noexcept;
|
int32_t <a href="#reverse_endianness">reverse_endianness</a>(int32_t x) noexcept;
|
||||||
@@ -108,34 +107,36 @@ namespace endian
|
|||||||
float <a href="#reverse_endianness">reverse_endianness</a>(float x) noexcept;
|
float <a href="#reverse_endianness">reverse_endianness</a>(float x) noexcept;
|
||||||
double <a href="#reverse_endianness">reverse_endianness</a>(double x) noexcept;
|
double <a href="#reverse_endianness">reverse_endianness</a>(double x) noexcept;
|
||||||
|
|
||||||
template <class Value>
|
|
||||||
void <a href="#reverse">reverse</a>(Value& x) noexcept;
|
|
||||||
|
|
||||||
// reverse byte order unless native endianness is big
|
|
||||||
template <class ReversibleValue >
|
|
||||||
ReversibleValue <a href="#big_endian_value">big_endian_value</a>(ReversibleValue x) noexcept;
|
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
void <a href="#big_endian">big_endian</a>(Reversible& x) noexcept;
|
Reversible big_to_native(Reversible x) noexcept;
|
||||||
|
|
||||||
// reverse byte order unless native endianness is little
|
|
||||||
template <class ReversibleValue >
|
|
||||||
ReversibleValue <a href="#little_endian_value">little_endian_value</a>(ReversibleValue x) noexcept;
|
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
void <a href="#little_endian">little_endian</a>(Reversible& x) noexcept;
|
Reversible native_to_big(Reversible x) noexcept;
|
||||||
|
|
||||||
// generic byte order conversion
|
|
||||||
template <order From, order To, class ReversibleValue>
|
|
||||||
ReversibleValue <a href="#convert_value_generic">convert_value</a>(ReversibleValue from) noexcept;
|
|
||||||
template <order From, order To, class Reversible>
|
|
||||||
void <a href="#convert_generic">convert</a>(Reversible& x) noexcept;
|
|
||||||
|
|
||||||
// runtime byte-order conversion
|
|
||||||
template <class ReversibleValue>
|
|
||||||
ReversibleValue <a href="#convert_value_runtime">convert_value</a>(ReversibleValue from,
|
|
||||||
order from_order, order to_order) noexcept;
|
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
void <a href="#convert_runtime">convert</a>(Reversible& x,
|
Reversible little_to_native(Reversible x) noexcept;
|
||||||
order from_order, order to_order) 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 runtime_conditional_reverse(Reversible x,
|
||||||
|
order order1, order order2) noexcept;
|
||||||
|
|
||||||
|
template <class Reversible>
|
||||||
|
void reverse_endianness_in_place(Reversible& x) noexcept;
|
||||||
|
|
||||||
|
template <class Reversible>
|
||||||
|
void big_to_native_in_place(Reversible& x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void native_to_big_in_place(Reversible& x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void little_to_native_in_place(Reversible& x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void native_to_little_in_place(Reversible& x) noexcept;
|
||||||
|
template <order O1, order O2, class Reversible>
|
||||||
|
void conditional_reverse_in_place(Reversible& x) noexcept;
|
||||||
|
template <class Reversible>
|
||||||
|
void runtime_conditional_reverse_in_place(Reversible& x,
|
||||||
|
order order1, order order2) noexcept;
|
||||||
|
|
||||||
} // namespace endian
|
} // namespace endian
|
||||||
} // namespace boost</pre>
|
} // namespace boost</pre>
|
||||||
@@ -226,81 +227,94 @@ double reverse_endianness(double x) noexcept;</pre>
|
|||||||
<p><i>Returns:</i> <i><code>x</code></i>, with the order of its
|
<p><i>Returns:</i> <i><code>x</code></i>, with the order of its
|
||||||
constituent bytes reversed.</p>
|
constituent bytes reversed.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre><a name="reverse"></a>template <class Value>
|
|
||||||
void reverse(Value& x) noexcept;</pre>
|
<pre>template <class Reversible>
|
||||||
<blockquote>
|
Reversible big_to_native(Reversible x) noexcept;</pre>
|
||||||
<p><i>Postconditions:</i> The order of the constituent bytes of
|
|
||||||
<code>x</code> are reversed.</p>
|
|
||||||
</blockquote>
|
|
||||||
<pre><a name="big_endian_value"></a>template <class ReversibleValue >
|
|
||||||
ReversibleValue big_endian_value(ReversibleValue x) noexcept;
|
|
||||||
<a name="big_endian"></a>template <class Reversible>
|
|
||||||
void big_endian(Reversible& x) noexcept;</pre>
|
|
||||||
<blockquote>
|
|
||||||
<p><i>Returns (first form)</i>: <code>x</code> if the native byte order is big
|
|
||||||
endian, otherwise <code>reverse_endianness(x)</code>.</p>
|
|
||||||
<p><i>Effects (second form):</i> None if the native byte order is big
|
|
||||||
endian, otherwise <code>reverse(x)</code>.</p>
|
|
||||||
<p><i>Example:</i></p>
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>int32_t x = <b><i>some-value</i></b>;
|
<p>
|
||||||
big_endian(x); // reverses the byte order of x, unless
|
<i>Returns:</i> <code>conditional_reverse<order::big,
|
||||||
// the native byte order is big-endian</pre>
|
order::native>(x)</code>.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
<pre>template <class Reversible>
|
||||||
<pre><a name="little_endian_value"></a>template <class ReversibleValue >
|
Reversible native_to_big(Reversible x) noexcept; </pre>
|
||||||
ReversibleValue little_endian_value(ReversibleValue x) noexcept;
|
|
||||||
<a name="little_endian"></a>template <class Reversible>
|
|
||||||
void little_endian(Reversible& x) noexcept;</pre>
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Returns (first form)</i>: <code>x</code> if the native byte order is little
|
<p><i>Returns:</i> <code>conditional_reverse<order::native, order::big>(x)</code>.</p>
|
||||||
endian, otherwise <code>reverse_endianness(x)</code>.</p>
|
|
||||||
<p><i>Effects (second form):</i> None if the native byte order is little
|
|
||||||
endian, otherwise <code>reverse(x)</code>.</p>
|
|
||||||
<p><i>Example:</i></p>
|
|
||||||
<blockquote>
|
|
||||||
<pre>int32_t x = <b><i>some-value</i></b>;
|
|
||||||
int32_t y(little_endian(x));
|
|
||||||
// y has been set to x; the byte order is reversed unless
|
|
||||||
// the native byte order is little-endian.</pre>
|
|
||||||
</blockquote>
|
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<pre><a name="convert_value_generic"></a>template <order From, order To, class ReversibleValue>
|
<pre>template <class Reversible>
|
||||||
ReversibleValue convert_value(ReversibleValue from) noexcept;
|
Reversible little_to_native(Reversible x) noexcept; </pre>
|
||||||
<a name="convert_generic"></a>template <order From, order To, class Reversible>
|
<blockquote>
|
||||||
void convert(Reversible& x) noexcept;
|
<p><i>Returns:</i> <code>conditional_reverse<order::little, order::native>(x)</code>.</p>
|
||||||
</pre>
|
</blockquote>
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
Reversible native_to_little(Reversible 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>
|
||||||
|
<blockquote>
|
||||||
|
<p><i>Returns:</i> <code>x</code> if <code>O1 == O2,</code> otherwise
|
||||||
|
<code>reverse_endianness(x)</code>.</p>
|
||||||
|
<p><i>Remarks: </i>Whether <code>x</code> or <code>reverse_endianness(x)</code>
|
||||||
|
is to be returned shall be determined at compile time.</p>
|
||||||
|
</blockquote>
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
Reversible runtime_conditional_reverse(Reversible x,
|
||||||
|
order order1, order order2) noexcept; </pre>
|
||||||
|
<blockquote>
|
||||||
|
<p><i>Returns:</i> <code>order1 == order2 ? x : reverse_endianness(x)</code>.</p>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
void reverse_endianness_in_place(Reversible& x) noexcept; </pre>
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>The <b><i>effective order</i></b> of an order template parameter
|
<p><i>Effects:</i> <code>x</code> <code>= reverse_endianness(x)</code>.</p>
|
||||||
is the same as the order template parameter if the parameter is not <code>
|
|
||||||
order::native</code>, otherwise it is the constant <code>order::big</code> or
|
|
||||||
<code>order::little</code> that represents the actual native byte order.</p>
|
|
||||||
<p><i>Returns (first form)</i>: <code>from</code> if <code>From</code>
|
|
||||||
and <code>To</code> have the same effective order, otherwise <code>
|
|
||||||
reverse_endianness(from)</code>.</p>
|
|
||||||
<p><i>Effects (second form):</i> None if <code>From</code> and <code>
|
|
||||||
To</code> have the same effective order, otherwise <code>reverse(x)</code>.</p>
|
|
||||||
<p><i>Example:</i></p>
|
|
||||||
<blockquote>
|
|
||||||
<pre>int32_t x;
|
|
||||||
<i>... read an external big-endian value into x</i>
|
|
||||||
convert<order::big, order::native>(x); // more generic equivalent of big_endian(x);</pre>
|
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
|
||||||
<pre><a name="convert_value_runtime"></a>template <class ReversibleValue>
|
<pre>template <class Reversible>
|
||||||
ReversibleValue convert_value(ReversibleValue from,
|
void big_to_native_in_place(Reversible& x) noexcept; </pre>
|
||||||
order from_order, order to_order) noexcept;
|
<blockquote>
|
||||||
<a name="convert_runtime"></a>template <class Reversible>
|
<p>
|
||||||
void convert(Reversible& x,
|
<i>Effects:</i> <code>conditional_reverse_in_place<order::big,
|
||||||
order from_order, order to_order) noexcept;</pre><blockquote><p><i>Returns (first form)</i>: <code>from</code> if <code>effect_order(from_order) == effective_order(to_order)</code>, otherwise <code>reverse_endianness(from)</code>.</p>
|
order::native>(x)</code>.</p>
|
||||||
<p><i>Effects (second form):</i> None if <code>effect_order(from_order) == effective_order(to_order)</code>, otherwise <code>reverse(x)</code>.</p>
|
|
||||||
<p><i>Example:</i></p>
|
|
||||||
<blockquote>
|
|
||||||
<pre>int32_t x;
|
|
||||||
<i>... read an external value of an endianness know only at runtime into x</i>
|
|
||||||
convert(x, some_order, order::native); // convert to native byte order if needed</pre>
|
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
<pre>template <class Reversible>
|
||||||
|
void native_to_big_in_place(Reversible& x) noexcept; </pre>
|
||||||
|
<blockquote>
|
||||||
|
<p>
|
||||||
|
<i>Effects:</i> <code>conditional_reverse_in_place<order::native,
|
||||||
|
order::big>(x)</code>.</p>
|
||||||
|
</blockquote>
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
void little_to_native_in_place(Reversible& x) noexcept; </pre>
|
||||||
|
<blockquote>
|
||||||
|
<p>
|
||||||
|
<i>Effects:</i> <code>conditional_reverse_in_place<order::little, order::native>(x)</code>.</p>
|
||||||
|
</blockquote>
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
void native_to_little_in_place(Reversible& x) noexcept; </pre>
|
||||||
|
<blockquote>
|
||||||
|
<p>
|
||||||
|
<i>Effects:</i> <code>conditional_reverse_in_place<order::native,
|
||||||
|
order::little>(x)</code>.</p>
|
||||||
|
</blockquote>
|
||||||
|
<pre>template <order O1, order O2, class Reversible>
|
||||||
|
void conditional_reverse_in_place(Reversible& x) noexcept; </pre>
|
||||||
|
<blockquote>
|
||||||
|
<p><i>Effects:</i> None if <code>O1 == O2,</code> otherwise
|
||||||
|
<code>reverse_endianness_in_place(x)</code>.</p>
|
||||||
|
<p><i>Remarks: </i>Which effect applies shall be determined at compile time.</p>
|
||||||
|
</blockquote>
|
||||||
|
<pre>template <class Reversible>
|
||||||
|
void runtime_conditional_reverse_in_place(Reversible& x,
|
||||||
|
order order1, order order2) noexcept; </pre>
|
||||||
|
|
||||||
|
|
||||||
|
<blockquote>
|
||||||
|
<p><i>Effects: </i>If <code>order1 == order2</code> then <code>reverse_endianness_in_place(x)</code>.</p>
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
|
||||||
<h2> <a name="FAQ">FAQ</a></h2>
|
<h2> <a name="FAQ">FAQ</a></h2>
|
||||||
|
|
||||||
@@ -325,7 +339,7 @@ wrong!</p>
|
|||||||
|
|
||||||
<p>Returning the result by value is the standard C and C++ idiom for functions that compute a
|
<p>Returning the result by value is the standard C and C++ idiom for functions that compute a
|
||||||
value from an argument. Modify-in-place functions allow cleaner code in many real-world
|
value from an argument. Modify-in-place functions allow cleaner code in many real-world
|
||||||
endian use cases and are more efficient for user defined types that have
|
endian use cases and are more efficient for user-defined types that have
|
||||||
members such as string data that do not need to be reversed. Thus both forms are
|
members such as string data that do not need to be reversed. Thus both forms are
|
||||||
provided.</p>
|
provided.</p>
|
||||||
|
|
||||||
@@ -337,7 +351,7 @@ Pierre Talbot provided the <code>int8_t reverse_endianness()</code> and template
|
|||||||
<code>reverse()</code> implementations.</p>
|
<code>reverse()</code> implementations.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Last revised:
|
<p>Last revised:
|
||||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->07 December, 2014<!--webbot bot="Timestamp" endspan i-checksum="38646" --></p>
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->09 December, 2014<!--webbot bot="Timestamp" endspan i-checksum="38650" --></p>
|
||||||
<p>© Copyright Beman Dawes, 2011, 2013</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>
|
<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>
|
||||||
|
|
||||||
|
@@ -68,17 +68,11 @@ int main(int, char* [])
|
|||||||
reverse_endianness_in_place(x);
|
reverse_endianness_in_place(x);
|
||||||
cout << "(3) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(3) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
reverse_in_place_unless_native_big(x);
|
conditional_reverse_in_place<order::little, order::big>(x);
|
||||||
cout << "(4) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(4) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
reverse_in_place_unless_native_little(x);
|
|
||||||
cout << "(5) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
|
||||||
|
|
||||||
conditional_reverse_in_place<order::little, order::big>(x);
|
|
||||||
cout << "(6) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
|
||||||
|
|
||||||
runtime_conditional_reverse_in_place(x, order::big, order::little);
|
runtime_conditional_reverse_in_place(x, order::big, order::little);
|
||||||
cout << "(7) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(5) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
||||||
|
@@ -72,9 +72,6 @@ namespace endian
|
|||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT;
|
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT;
|
||||||
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
||||||
template <class Reversible >
|
|
||||||
inline Reversible reverse_unless_native_big(Reversible x) BOOST_NOEXCEPT;
|
|
||||||
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
|
||||||
|
|
||||||
// reverse byte order unless native endianness is little
|
// reverse byte order unless native endianness is little
|
||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
@@ -83,9 +80,6 @@ namespace endian
|
|||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT;
|
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT;
|
||||||
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
||||||
template <class Reversible >
|
|
||||||
inline Reversible reverse_unless_native_little(Reversible x) BOOST_NOEXCEPT;
|
|
||||||
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
|
||||||
|
|
||||||
// generic conditional reverse byte order
|
// generic conditional reverse byte order
|
||||||
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 Reversible>
|
||||||
@@ -140,9 +134,6 @@ namespace endian
|
|||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT;
|
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
||||||
template <class Reversible>
|
|
||||||
inline void reverse_in_place_unless_native_big(Reversible& x) BOOST_NOEXCEPT;
|
|
||||||
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
|
||||||
|
|
||||||
// reverse in place unless native endianness is little
|
// reverse in place unless native endianness is little
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
@@ -151,9 +142,6 @@ namespace endian
|
|||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT;
|
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
||||||
template <class Reversible>
|
|
||||||
inline void reverse_in_place_unless_native_little(Reversible& x) BOOST_NOEXCEPT;
|
|
||||||
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
|
||||||
|
|
||||||
// generic conditional reverse in place
|
// generic conditional reverse in place
|
||||||
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 Reversible>
|
||||||
@@ -328,16 +316,6 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Reversible >
|
|
||||||
inline Reversible reverse_unless_native_big(Reversible x) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
|
||||||
return x;
|
|
||||||
# else
|
|
||||||
return reverse_endianness(x);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT
|
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
@@ -358,16 +336,6 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Reversible >
|
|
||||||
inline Reversible reverse_unless_native_little(Reversible x) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
# ifdef BOOST_LITTLE_ENDIAN
|
|
||||||
return x;
|
|
||||||
# else
|
|
||||||
return reverse_endianness(x);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
// Primary template and specializations to support reverse_endianness().
|
// Primary template and specializations to support reverse_endianness().
|
||||||
@@ -413,9 +381,6 @@ namespace endian
|
|||||||
x = reverse_endianness(x);
|
x = reverse_endianness(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse in place unless native endianness is big
|
|
||||||
// Effects: none if native endian order is big,
|
|
||||||
// otherwise reverse_endianness_in_place(x)
|
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
inline void big_to_native_in_place(Reversible&) BOOST_NOEXCEPT {}
|
inline void big_to_native_in_place(Reversible&) BOOST_NOEXCEPT {}
|
||||||
@@ -432,19 +397,7 @@ namespace endian
|
|||||||
reverse_endianness_in_place(x);
|
reverse_endianness_in_place(x);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
template <class Reversible>
|
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
|
||||||
inline void reverse_in_place_unless_native_big(Reversible&) BOOST_NOEXCEPT {}
|
|
||||||
# else
|
|
||||||
inline void reverse_in_place_unless_native_big(Reversible& x) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
reverse_endianness_in_place(x);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// reverse in place unless native endianness is little
|
|
||||||
// Effects: none if native endian order is little,
|
|
||||||
// otherwise reverse_endianness_in_place(x)
|
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
# ifdef BOOST_LITTLE_ENDIAN
|
# ifdef BOOST_LITTLE_ENDIAN
|
||||||
inline void little_to_native_in_place(Reversible&) BOOST_NOEXCEPT {}
|
inline void little_to_native_in_place(Reversible&) BOOST_NOEXCEPT {}
|
||||||
@@ -461,15 +414,6 @@ namespace endian
|
|||||||
reverse_endianness_in_place(x);
|
reverse_endianness_in_place(x);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
template <class Reversible>
|
|
||||||
# ifdef BOOST_LITTLE_ENDIAN
|
|
||||||
inline void reverse_in_place_unless_native_little(Reversible&) BOOST_NOEXCEPT {}
|
|
||||||
# else
|
|
||||||
inline void reverse_in_place_unless_native_little(Reversible& x) BOOST_NOEXCEPT
|
|
||||||
{
|
|
||||||
reverse_endianness_in_place(x);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
@@ -20,43 +20,67 @@
|
|||||||
namespace user
|
namespace user
|
||||||
{
|
{
|
||||||
|
|
||||||
int16_t return_x_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT {return x;}
|
int16_t return_x_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int16_t return_x_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT {return x;}
|
int16_t return_x_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int16_t return_x_value_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
int16_t return_x_value_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_big(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::big>(x);
|
||||||
|
}
|
||||||
int16_t return_x_value_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
int16_t return_x_value_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_little(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::little>(x);
|
||||||
|
}
|
||||||
int16_t return_x_in_place_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
int16_t return_x_in_place_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_big(x);return x;}
|
{
|
||||||
|
conditional_reverse_in_place<order::native, order::big>(x); return x;
|
||||||
|
}
|
||||||
int16_t return_x_in_place_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
int16_t return_x_in_place_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_little(x);return x;}
|
{
|
||||||
int16_t return_y_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT {return y;}
|
conditional_reverse_in_place<order::native, order::little>(x); return x;
|
||||||
int16_t return_y_little_int16(int16_t x, little_int16_ut y) BOOST_NOEXCEPT {return y;}
|
}
|
||||||
|
int16_t return_y_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
int16_t return_y_little_int16(int16_t x, little_int16_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
|
||||||
int32_t return_x_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT {return x;}
|
int32_t return_x_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int32_t return_x_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT {return x;}
|
int32_t return_x_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int32_t return_x_value_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
int32_t return_x_value_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_big(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::big>(x);
|
||||||
|
}
|
||||||
int32_t return_x_value_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
int32_t return_x_value_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_little(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::little>(x);
|
||||||
|
}
|
||||||
int32_t return_x_in_place_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
int32_t return_x_in_place_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_big(x);return x;}
|
{
|
||||||
|
conditional_reverse_in_place<order::native, order::big>(x); return x;
|
||||||
|
}
|
||||||
int32_t return_x_in_place_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
int32_t return_x_in_place_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_little(x);return x;}
|
{
|
||||||
int32_t return_y_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT {return y;}
|
conditional_reverse_in_place<order::native, order::little>(x); return x;
|
||||||
int32_t return_y_little_int32(int32_t x, little_int32_ut y) BOOST_NOEXCEPT {return y;}
|
}
|
||||||
|
int32_t return_y_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
int32_t return_y_little_int32(int32_t x, little_int32_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
|
||||||
int64_t return_x_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT {return x;}
|
int64_t return_x_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int64_t return_x_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT {return x;}
|
int64_t return_x_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT { return x; }
|
||||||
int64_t return_x_value_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
int64_t return_x_value_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_big(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::big>(x);
|
||||||
|
}
|
||||||
int64_t return_x_value_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
int64_t return_x_value_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
||||||
{return reverse_unless_native_little(x);}
|
{
|
||||||
|
return conditional_reverse<order::native, order::little>(x);
|
||||||
|
}
|
||||||
int64_t return_x_in_place_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
int64_t return_x_in_place_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_big(x);return x;}
|
{
|
||||||
|
conditional_reverse_in_place<order::native, order::big>(x); return x;
|
||||||
|
}
|
||||||
int64_t return_x_in_place_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
int64_t return_x_in_place_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
||||||
{reverse_in_place_unless_native_little(x);return x;}
|
{
|
||||||
int64_t return_y_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT {return y;}
|
conditional_reverse_in_place<order::native, order::little>(x); return x;
|
||||||
int64_t return_y_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT {return y;}
|
}
|
||||||
|
int64_t return_y_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
int64_t return_y_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT { return y; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user