From 37e2b011136ca1cf00dfb9e575d12f0d035a6a2c Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 2 Aug 2023 10:24:20 +0200 Subject: [refactor] Allow std::array in serialize.h This is already possible for C-style arrays, so allow it for C++11 std::array as well. --- src/serialize.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/serialize.h b/src/serialize.h index 2d790190a0..f1595077e9 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -285,6 +285,7 @@ template inline void Serialize(Stream& s, int64_t a ) { ser_wri template inline void Serialize(Stream& s, uint64_t a) { ser_writedata64(s, a); } template inline void Serialize(Stream& s, const char (&a)[N]) { s.write(MakeByteSpan(a)); } template inline void Serialize(Stream& s, const unsigned char (&a)[N]) { s.write(MakeByteSpan(a)); } +template void Serialize(Stream& s, const std::array& a) { (void)/* force byte-type */UCharCast(a.data()); s.write(MakeByteSpan(a)); } template void Serialize(Stream& s, Span span) { (void)/* force byte-type */UCharCast(span.data()); s.write(AsBytes(span)); } #ifndef CHAR_EQUALS_INT8 @@ -301,6 +302,7 @@ template inline void Unserialize(Stream& s, int64_t& a ) { a = template inline void Unserialize(Stream& s, uint64_t& a) { a = ser_readdata64(s); } template inline void Unserialize(Stream& s, char (&a)[N]) { s.read(MakeWritableByteSpan(a)); } template inline void Unserialize(Stream& s, unsigned char (&a)[N]) { s.read(MakeWritableByteSpan(a)); } +template void Unserialize(Stream& s, std::array& a) { (void)/* force byte-type */UCharCast(a.data()); s.read(MakeWritableByteSpan(a)); } template void Unserialize(Stream& s, Span span) { (void)/* force byte-type */UCharCast(span.data()); s.read(AsWritableBytes(span)); } template inline void Serialize(Stream& s, bool a) { uint8_t f = a; ser_writedata8(s, f); } -- cgit v1.2.3