From 1edf4dd7ef6085e52f9be669601c88cb8f48f166 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 09:32:13 -0400 Subject: common/swap: Use using aliases where applicable --- src/common/swap.h | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/common/swap.h b/src/common/swap.h index f025f7450..23f327201 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -167,7 +167,7 @@ inline double swapd(double f) { template struct swap_struct_t { - typedef swap_struct_t swapped_t; + using swapped_t = swap_struct_t; protected: T value = T(); @@ -606,51 +606,51 @@ struct swap_double_t { }; #if COMMON_LITTLE_ENDIAN -typedef u32 u32_le; -typedef u16 u16_le; -typedef u64 u64_le; +using u16_le = u16; +using u32_le = u32; +using u64_le = u64; -typedef s32 s32_le; -typedef s16 s16_le; -typedef s64 s64_le; +using s16_le = s16; +using s32_le = s32; +using s64_le = s64; -typedef float float_le; -typedef double double_le; +using float_le = float; +using double_le = double; -typedef swap_struct_t> u64_be; -typedef swap_struct_t> s64_be; +using u64_be = swap_struct_t>; +using s64_be = swap_struct_t>; -typedef swap_struct_t> u32_be; -typedef swap_struct_t> s32_be; +using u32_be = swap_struct_t>; +using s32_be = swap_struct_t>; -typedef swap_struct_t> u16_be; -typedef swap_struct_t> s16_be; +using u16_be = swap_struct_t>; +using s16_be = swap_struct_t>; -typedef swap_struct_t> float_be; -typedef swap_struct_t> double_be; +using float_be = swap_struct_t>; +using double_be = swap_struct_t>; #else -typedef swap_struct_t> u64_le; -typedef swap_struct_t> s64_le; +using u64_le = swap_struct_t>; +using s64_le = swap_struct_t>; -typedef swap_struct_t> u32_le; -typedef swap_struct_t> s32_le; +using u32_le = swap_struct_t>; +using s32_le = swap_struct_t>; -typedef swap_struct_t> u16_le; -typedef swap_struct_t> s16_le; +using u16_le = swap_struct_t>; +using s16_le = swap_struct_t>; -typedef swap_struct_t> float_le; -typedef swap_struct_t> double_le; +using float_le = swap_struct_t>; +using double_le = swap_struct_t>; -typedef u32 u32_be; -typedef u16 u16_be; -typedef u64 u64_be; +using u16_be = u16; +using u32_be = u32; +using u64_be = u64; -typedef s32 s32_be; -typedef s16 s16_be; -typedef s64 s64_be; +using s16_be = s16; +using s32_be = s32; +using s64_be = s64; -typedef float float_be; -typedef double double_be; +using float_be = float; +using double_be = double; #endif -- cgit v1.2.3 From 0a868641fa3eba59c2e20f553c6027d43e4a73a4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 09:35:13 -0400 Subject: common/swap: Use static_cast where applicable --- src/common/swap.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/common/swap.h b/src/common/swap.h index 23f327201..295c65993 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -185,39 +185,39 @@ public: template swapped_t& operator=(const S& source) { - value = swap((T)source); + value = swap(static_cast(source)); return *this; } operator s8() const { - return (s8)swap(); + return static_cast(swap()); } operator u8() const { - return (u8)swap(); + return static_cast(swap()); } operator s16() const { - return (s16)swap(); + return static_cast(swap()); } operator u16() const { - return (u16)swap(); + return static_cast(swap()); } operator s32() const { - return (s32)swap(); + return static_cast(swap()); } operator u32() const { - return (u32)swap(); + return static_cast(swap()); } operator s64() const { - return (s64)swap(); + return static_cast(swap()); } operator u64() const { - return (u64)swap(); + return static_cast(swap()); } operator float() const { - return (float)swap(); + return static_cast(swap()); } operator double() const { - return (double)swap(); + return static_cast(swap()); } // +v @@ -253,7 +253,7 @@ public: } template swapped_t operator+(const S& i) const { - return swap() + (T)i; + return swap() + static_cast(i); } // v - 5 swapped_t operator-(const swapped_t& i) const { @@ -261,7 +261,7 @@ public: } template swapped_t operator-(const S& i) const { - return swap() - (T)i; + return swap() - static_cast(i); } // v += 5 @@ -271,7 +271,7 @@ public: } template swapped_t& operator+=(const S& i) { - value = swap(swap() + (T)i); + value = swap(swap() + static_cast(i)); return *this; } // v -= 5 @@ -281,7 +281,7 @@ public: } template swapped_t& operator-=(const S& i) { - value = swap(swap() - (T)i); + value = swap(swap() - static_cast(i)); return *this; } @@ -541,7 +541,7 @@ S operator&(const S& i, const swap_struct_t v) { template S operator&(const swap_struct_t v, const S& i) { - return (S)(v.swap() & i); + return static_cast(v.swap() & i); } // Comparaison -- cgit v1.2.3 From 5c47ea1a4e285920f33497f6afd85658c07a102f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 19 Jul 2018 09:35:50 -0400 Subject: common/swap: Remove unnecessary const on return value of swap() --- src/common/swap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/swap.h b/src/common/swap.h index 295c65993..fc7af4280 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -177,7 +177,7 @@ protected: } public: - T const swap() const { + T swap() const { return swap(value); } swap_struct_t() = default; -- cgit v1.2.3