mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Add relational comparison operators to byte
This commit is contained in:
parent
31421d5cc3
commit
c378f089b4
@ -111,10 +111,15 @@ inline constexpr byte to_byte() noexcept
|
|||||||
// use of byte within span<> to be standards-compliant
|
// use of byte within span<> to be standards-compliant
|
||||||
struct byte {
|
struct byte {
|
||||||
unsigned char v;
|
unsigned char v;
|
||||||
|
|
||||||
explicit operator unsigned char&() { return v; }
|
explicit operator unsigned char&() { return v; }
|
||||||
explicit operator const unsigned char&() const { 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; }
|
||||||
|
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>>
|
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
|
||||||
|
Loading…
Reference in New Issue
Block a user