BAN: Add NetworkEndian to Endianness

This commit is contained in:
Bananymous 2024-02-02 03:13:14 +02:00
parent ab150b458a
commit acd6c86f98
1 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,11 @@ namespace BAN
template<integral T> template<integral T>
struct LittleEndian struct LittleEndian
{ {
constexpr LittleEndian(T 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);
@ -69,6 +74,11 @@ namespace BAN
template<integral T> template<integral T>
struct BigEndian struct BigEndian
{ {
constexpr BigEndian(T 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);
@ -77,4 +87,7 @@ namespace BAN
T raw; T raw;
}; };
template<integral T>
using NetworkEndian = BigEndian<T>;
} }