BAN: Add default constructors for BAN::{Little,Big}Endian

This commit is contained in:
Bananymous 2024-11-21 13:34:12 +02:00
parent 97718b4046
commit 31d2a39540
1 changed files with 14 additions and 6 deletions

View File

@ -70,15 +70,19 @@ namespace BAN
template<integral T> template<integral T>
struct LittleEndian struct LittleEndian
{ {
constexpr LittleEndian()
: raw(0)
{ }
constexpr LittleEndian(T value) constexpr LittleEndian(T value)
{ : raw(host_to_little_endian(value))
raw = host_to_little_endian(value); { }
}
constexpr operator T() const constexpr operator T() const
{ {
return host_to_little_endian(raw); return host_to_little_endian(raw);
} }
private: private:
T raw; T raw;
}; };
@ -86,15 +90,19 @@ namespace BAN
template<integral T> template<integral T>
struct BigEndian struct BigEndian
{ {
constexpr BigEndian()
: raw(0)
{ }
constexpr BigEndian(T value) constexpr BigEndian(T value)
{ : raw(host_to_big_endian(value))
raw = host_to_big_endian(value); { }
}
constexpr operator T() const constexpr operator T() const
{ {
return host_to_big_endian(raw); return host_to_big_endian(raw);
} }
private: private:
T raw; T raw;
}; };