aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-30 12:00:20 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-30 12:09:45 +0200
commitfac6af16f4a254458b8cb3522317422b40362f8d (patch)
tree39ca5ca662157ed3fb66105c5a3d123e3ec6a640 /src/serialize.h
parentfade43edc4405e7c51cec9325d8502f3786f7438 (diff)
Allow std::byte serialization
Diffstat (limited to 'src/serialize.h')
-rw-r--r--src/serialize.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/serialize.h b/src/serialize.h
index cf865eb3f4..0cda0ac7d5 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -192,6 +192,7 @@ template<typename X> const X& ReadWriteAsHelper(const X& x) { return x; }
#ifndef CHAR_EQUALS_INT8
template <typename Stream> void Serialize(Stream&, char) = delete; // char serialization forbidden. Use uint8_t or int8_t
#endif
+template <typename Stream> void Serialize(Stream& s, std::byte a) { ser_writedata8(s, uint8_t(a)); }
template<typename Stream> inline void Serialize(Stream& s, int8_t a ) { ser_writedata8(s, a); }
template<typename Stream> inline void Serialize(Stream& s, uint8_t a ) { ser_writedata8(s, a); }
template<typename Stream> inline void Serialize(Stream& s, int16_t a ) { ser_writedata16(s, a); }
@@ -207,6 +208,7 @@ template <typename Stream, typename B> void Serialize(Stream& s, Span<B> span) {
#ifndef CHAR_EQUALS_INT8
template <typename Stream> void Unserialize(Stream&, char) = delete; // char serialization forbidden. Use uint8_t or int8_t
#endif
+template <typename Stream> void Unserialize(Stream& s, std::byte& a) { a = std::byte{ser_readdata8(s)}; }
template<typename Stream> inline void Unserialize(Stream& s, int8_t& a ) { a = ser_readdata8(s); }
template<typename Stream> inline void Unserialize(Stream& s, uint8_t& a ) { a = ser_readdata8(s); }
template<typename Stream> inline void Unserialize(Stream& s, int16_t& a ) { a = ser_readdata16(s); }