BAN: Add NetworkEndian to Endianness
This commit is contained in:
parent
ab150b458a
commit
acd6c86f98
|
@ -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>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue