diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-01-14 21:13:29 +0100 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-01-15 23:06:31 -0500 |
commit | d1711f1cefc2940b96f995334b7859605fa349f0 (patch) | |
tree | 55c262f71462dd084444461d72b3e24868068d59 /AK/Traits.h | |
parent | 6777cb097553d9d72dd335e3caf0ad9c664add2d (diff) | |
download | serenity-d1711f1cefc2940b96f995334b7859605fa349f0.zip |
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.
Diffstat (limited to 'AK/Traits.h')
-rw-r--r-- | AK/Traits.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/AK/Traits.h b/AK/Traits.h index 27efd35446..cdcb9a85f7 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -20,6 +20,7 @@ struct GenericTraits { using PeekType = T&; using ConstPeekType = T const&; static constexpr bool is_trivial() { return false; } + static constexpr bool is_trivially_serializable() { return false; } static constexpr bool equals(T const& a, T const& b) { return a == b; } template<Concepts::HashCompatible<T> U> static bool equals(U const& a, T const& b) { return a == b; } @@ -32,6 +33,7 @@ struct Traits : public GenericTraits<T> { template<Integral T> struct Traits<T> : public GenericTraits<T> { static constexpr bool is_trivial() { return true; } + static constexpr bool is_trivially_serializable() { return true; } static constexpr unsigned hash(T value) { if constexpr (sizeof(T) < 8) @@ -45,6 +47,7 @@ struct Traits<T> : public GenericTraits<T> { template<FloatingPoint T> struct Traits<T> : public GenericTraits<T> { static constexpr bool is_trivial() { return true; } + static constexpr bool is_trivially_serializable() { return true; } static constexpr unsigned hash(T value) { if constexpr (sizeof(T) < 8) @@ -65,6 +68,7 @@ template<Enum T> struct Traits<T> : public GenericTraits<T> { static unsigned hash(T value) { return Traits<UnderlyingType<T>>::hash(to_underlying(value)); } static constexpr bool is_trivial() { return Traits<UnderlyingType<T>>::is_trivial(); } + static constexpr bool is_trivially_serializable() { return Traits<UnderlyingType<T>>::is_trivially_serializable(); } }; template<typename T> |