1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:17:35 +00:00

LibIPC: Add support for encoding and decoding Array<T, N>

Also add a note to the Concepts header that the reason we have all the
strange concepts in place for container types is to work around the
language limitation that we cannot partially specialize function
templates.
This commit is contained in:
Andrew Kaster 2024-03-05 09:12:18 -07:00 committed by Andreas Kling
parent e09bfc1a8c
commit 7e6918e14a
3 changed files with 33 additions and 0 deletions

View file

@ -108,6 +108,17 @@ ErrorOr<void> encode(Encoder&, File const&);
template<>
ErrorOr<void> encode(Encoder&, Empty const&);
template<typename T, size_t N>
ErrorOr<void> encode(Encoder& encoder, Array<T, N> const& array)
{
TRY(encoder.encode_size(array.size()));
for (auto const& value : array)
TRY(encoder.encode(value));
return {};
}
template<Concepts::Vector T>
ErrorOr<void> encode(Encoder& encoder, T const& vector)
{