From 086b4067488519b382d0c2c59536da5efccb2428 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 9 Mar 2018 21:48:16 -0600 Subject: [PATCH] Remove some unnecessary operators from ox::LittleEndian --- deps/ox/src/ox/std/byteswap.hpp | 48 +++++++++++---------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/deps/ox/src/ox/std/byteswap.hpp b/deps/ox/src/ox/std/byteswap.hpp index 4a462ada..966e2fdf 100644 --- a/deps/ox/src/ox/std/byteswap.hpp +++ b/deps/ox/src/ox/std/byteswap.hpp @@ -79,7 +79,7 @@ inline T bigEndianAdapt(T i) { template -class __attribute__((packed)) LittleEndian { +class LittleEndian { private: T m_value; @@ -99,7 +99,8 @@ class __attribute__((packed)) LittleEndian { return *this; } - inline T operator=(T value) { + template + inline T operator=(I value) { m_value = ox::bigEndianAdapt(value); return value; } @@ -137,7 +138,7 @@ class __attribute__((packed)) LittleEndian { } // Prefix increment - inline T &operator++() { + inline T operator++() { return operator+=(1); } @@ -149,7 +150,7 @@ class __attribute__((packed)) LittleEndian { } // Prefix decrement - inline T &operator--() { + inline T operator--() { return operator-=(1); } @@ -160,55 +161,36 @@ class __attribute__((packed)) LittleEndian { return old; } - inline T operator~() const { - return ~ox::bigEndianAdapt(m_value); - } - - inline T operator&(T value) const { - return ox::bigEndianAdapt(m_value) & value; - } - - inline T operator&=(T other) { + template + inline T operator&=(I other) { auto newVal = *this & other; m_value = ox::bigEndianAdapt(newVal); return newVal; } - inline T operator|(T value) const { - return ox::bigEndianAdapt(m_value) | value; - } - - inline T operator|=(T other) { + template + inline T operator|=(I other) { auto newVal = *this | other; m_value = ox::bigEndianAdapt(newVal); return newVal; } - inline T operator^(T value) const { - return ox::bigEndianAdapt(m_value) ^ value; - } - - inline T operator^=(T other) { + template + inline T operator^=(I other) { auto newVal = *this ^ other; m_value = ox::bigEndianAdapt(newVal); return newVal; } - inline T operator>>(T value) const { - return ox::bigEndianAdapt(m_value) >> value; - } - - inline T operator>>=(T other) { + template + inline T operator>>=(I other) { auto newVal = *this >> other; m_value = ox::bigEndianAdapt(newVal); return newVal; } - inline T operator<<(T value) const { - return ox::bigEndianAdapt(m_value) << value; - } - - inline T operator<<=(T other) { + template + inline T operator<<=(I other) { auto newVal = *this << other; m_value = ox::bigEndianAdapt(newVal); return newVal;