mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
AK: Define our own concept of "trivially serializable"
While at it, rename the `read_trivial_value` and `write_trivial_value` functions to `read_value` and `write_value` respectively, since we'll add compatibility for non-trivial types down the line.
This commit is contained in:
parent
6777cb0975
commit
d1711f1cef
5 changed files with 23 additions and 14 deletions
|
@ -109,8 +109,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
requires(IsTriviallyDestructible<T>)
|
||||
ErrorOr<T> read_trivial_value()
|
||||
requires(Traits<T>::is_trivially_serializable())
|
||||
ErrorOr<T> read_value()
|
||||
{
|
||||
alignas(T) u8 buffer[sizeof(T)] = {};
|
||||
TRY(read_entire_buffer({ &buffer, sizeof(buffer) }));
|
||||
|
@ -118,8 +118,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
requires(IsTriviallyDestructible<T>)
|
||||
ErrorOr<void> write_trivial_value(T const& value)
|
||||
requires(Traits<T>::is_trivially_serializable())
|
||||
ErrorOr<void> write_value(T const& value)
|
||||
{
|
||||
return write_entire_buffer({ &value, sizeof(value) });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue