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