Add relational comparison operators to byte

This commit is contained in:
MikeGitb 2016-09-20 18:06:48 +02:00
parent 31421d5cc3
commit c378f089b4

View File

@ -111,10 +111,15 @@ inline constexpr byte to_byte() noexcept
// use of byte within span<> to be standards-compliant
struct byte {
unsigned char v;
explicit operator unsigned char&() { return v; }
explicit operator const unsigned char&() const { return v; }
friend bool operator==(byte l, byte r) { return l.v == r.v; }
friend bool operator!=(byte l, byte r) { return l.v != r.v; }
friend bool operator<(byte l, byte r) { return l.v < r.v; }
friend bool operator<=(byte l, byte r) { return l.v <= r.v; }
friend bool operator>(byte l, byte r) { return l.v > r.v; }
friend bool operator>=(byte l, byte r) { return l.v >= r.v; }
};
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>