From 66a7a0bfac957e5b4f4ea34f09592e67fa74cc5d Mon Sep 17 00:00:00 2001
From: Beman
Functions are implemented if appropriate. noexcept
is
+
Functions are implemented inline
if appropriate. noexcept
is
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.
<boost/endian/conversion.hpp>
@@ -91,9 +93,9 @@ namespace endian
{
enum class order
{
- big, // big-endian
- little, // little-endian
- native = implementation-defined // same as order::big or order::little
+ big, // big endian
+ little, // little endian
+ native = implementation-defined-as-big-or-little
};
int8_t endian_reverse(int8_t x) noexcept;
@@ -328,18 +330,6 @@ void conditional_reverse_inplace(Reversible& x,
See the Endian home page FAQ for a library-wide FAQ.
-Why are the template versions of reverse()
and endian_reverse()
-in a detail namespace?
- --They are unsafe for general use. Consider reversing -the bytes of a
- -std::pair
as a whole - the bytes fromfirst
-would end up insecond
and visa versa, and this is totally -wrong!
Why are both value returning and modify-in-place functions provided?
@@ -355,7 +345,7 @@ provided.Acknowledgements
Tomas Puverle was instrumental in identifying and articulating the need to support endian conversion as separate from endian integer types. Phil Endecott suggested the form of the value returning signatures. Vicente Botet and other reviewers suggested supporting floating point types and user defined types. General reverse template implementation approach using std::reverse suggested by Mathias Gaunard. Portable implementation approach for 16, 32, and 64-bit integers suggested by tymofey, with avoidance of undefined behavior as suggested by Giovanni Piero Deretta, and a further refinement suggested by Pyry Jahkola. Intrinsic builtins implementation approach for 16, 32, and 64-bit integers suggested by several reviewers, and by David Stone, who provided his Boost licensed macro implementation that became the starting point for boost/endian/detail/intrinsic.hpp. Pierre Talbot provided the
+int8_t endian_reverse()
and templated -reverse()
implementations.endian_reverse_inplace()
implementations.
Last revised: 10 December, 2014