mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
AK: Add {Little,Big}Endian::bytes()
This allows you to easily convert those types to ReadonlyBytes.
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
||||
|
||||
constexpr operator T() const { return convert_between_host_and_little_endian(m_value); }
|
||||
|
||||
constexpr ReadonlyBytes bytes() const { return { this, sizeof(*this) }; }
|
||||
|
||||
private:
|
||||
T m_value { 0 };
|
||||
};
|
||||
@@ -81,6 +83,8 @@ public:
|
||||
|
||||
constexpr operator T() const { return convert_between_host_and_big_endian(m_value); }
|
||||
|
||||
constexpr ReadonlyBytes bytes() const { return { this, sizeof(*this) }; }
|
||||
|
||||
private:
|
||||
T m_value { 0 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user