From 1fc19c5a27a5734d5bc773bf35eaa78febb931d8 Mon Sep 17 00:00:00 2001 From: Beman Date: Sun, 19 May 2013 07:15:09 -0400 Subject: [PATCH] Rename actual_order to effective_order. We don't know the actual order. Simplify an expression. --- include/boost/endian/conversion.hpp | 38 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index e9090bc..bea08fe 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -61,18 +61,18 @@ namespace endian // 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 T bswap(T x) {return reverse_value(x);} - template T htobe(T host_) {return big_endian_value(host_);} - template T htole(T host_) {return little_endian_value(host_);} - template T betoh(T big_endian_) {return big_endian_value(big_endian_);} - template T letoh(T little_endian_) {return little_endian_value(little_endian_);} + template inline T bswap(T x) BOOST_NOEXCEPT {return reverse_value(x);} + template inline T htobe(T host) BOOST_NOEXCEPT {return big_endian_value(host);} + template inline T htole(T host) BOOST_NOEXCEPT {return little_endian_value(host);} + template inline T betoh(T big) BOOST_NOEXCEPT {return big_endian_value(big);} + template inline T letoh(T little) BOOST_NOEXCEPT {return little_endian_value(little);} // compile-time generic byte order conversion template 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; + inline BOOST_SCOPED_ENUM(order) effective_order(BOOST_SCOPED_ENUM(order) o) BOOST_NOEXCEPT; // Return: o if o != native, otherwise big or little depending on native ordering // runtime byte-order conversion @@ -108,11 +108,11 @@ namespace endian // 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 void mbswap(T& x) {reverse(x);} - template void mhtobe(T& host_) {big_endian(host_);} - template void mhtole(T& host_) {little_endian(host_);} - template void mbetoh(T& big_endian_) {big_endian(big_endian_);} - template void mletoh(T& little_endian_) {little_endian(little_endian_);} + template inline void mbswap(T& x) BOOST_NOEXCEPT {reverse(x);} + template inline void mhtobe(T& host) BOOST_NOEXCEPT {big_endian(host);} + template inline void mhtole(T& host) BOOST_NOEXCEPT {little_endian(host);} + template inline void mbetoh(T& big) BOOST_NOEXCEPT {big_endian(big);} + template inline void mletoh(T& little) BOOST_NOEXCEPT {little_endian(little);} // compile-time generic byte order conversion template @@ -296,7 +296,7 @@ namespace endian # endif } - // compile-time generic convert_valuereturn by value + // compile-time generic convert return by value template Reversible convert_value(Reversible x) BOOST_NOEXCEPT { @@ -307,7 +307,7 @@ namespace endian return tmp(x); } - inline BOOST_SCOPED_ENUM(order) actual_order(BOOST_SCOPED_ENUM(order) o) BOOST_NOEXCEPT + inline BOOST_SCOPED_ENUM(order) effective_order(BOOST_SCOPED_ENUM(order) o) BOOST_NOEXCEPT { return o != order::native ? o : # ifdef BOOST_LITTLE_ENDIAN @@ -322,10 +322,8 @@ namespace endian ReversibleValue convert_value(ReversibleValue from, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT { - if (actual_order(from_order) == order::big) - return actual_order(to_order) == order::big ? from : reverse_value(from); - // actual from_order is little - return actual_order(to_order) == order::little ? from : reverse_value(from); + return effective_order(from_order) == effective_order(to_order) + ? from : reverse_value(from); } //--------------------------------------------------------------------------------------// @@ -403,14 +401,14 @@ namespace endian void convert(Reversible& x, BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order) BOOST_NOEXCEPT { - if (actual_order(from_order) == order::big) + if (effective_order(from_order) == order::big) { - if (actual_order(to_order) != order::big) + if (effective_order(to_order) != order::big) reverse(x); } else // actual from_order is little { - if (actual_order(to_order) != order::little) + if (effective_order(to_order) != order::little) reverse(x); } }