Add synonyms based on names popularized by BSD, e.g. OS X, Linux.

This commit is contained in:
Beman committed 2013-05-15 08:51:05 -04:00
1 parent 09b361e161
commit 8b4bd2adfc
2 files changed
+52 -1

No files matched your search

+18 -1
View File
@@ -70,9 +70,17 @@ namespace endian
inline ReversibleValue little_endian_value(ReversibleValue x) BOOST_NOEXCEPT;
// Return: x if native endian order is little, otherwise reverse_value(x);
// synonyms based on names popularized by BSD, e.g. OS X, Linux
// "h" stands for "host" (i.e. native), "be" for "big endian", "le" for "little endian"
template <class T> T bswap(T x) {return reverse_value(x);}
template <class T> T htobe(T host_) {return big_endian_value(host_);}
template <class T> T htole(T host_) {return little_endian_value(host_);}
template <class T> T betoh(T big_endian_) {return big_endian_value(big_endian_);}
template <class T> T letoh(T little_endian_) {return little_endian_value(little_endian_);}
// compile-time generic byte order conversion
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class ReversibleValue >
ReversibleValue convert_value(ReversibleValue from) BOOST_NOEXCEPT;
ReversibleValue convert_value(ReversibleValue from) BOOST_NOEXCEPT;
// runtime actual byte-order determination
inline BOOST_SCOPED_ENUM(order) actual_order(BOOST_SCOPED_ENUM(order) o) BOOST_NOEXCEPT;
@@ -108,6 +116,15 @@ namespace endian
inline void little_endian(Reversible& x) BOOST_NOEXCEPT;
// Effects: none if native endian order is little, otherwise reverse(x);
// synonyms based on names popularized by BSD, e.g. OS X, Linux.
// "h" stands for "host" (i.e. native), "be" for "big endian",
// "le" for "little endian", "m" for "modify in place"
template <class T> void mbswap(T& x) {reverse(x);}
template <class T> void mhtobe(T& host_) {big_endian(host_);}
template <class T> void mhtole(T& host_) {little_endian(host_);}
template <class T> void mbetoh(T& big_endian_) {big_endian(big_endian_);}
template <class T> void mletoh(T& little_endian_) {little_endian(little_endian_);}
// compile-time generic byte order conversion
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
void convert(Reversible& x) BOOST_NOEXCEPT;