diff --git a/src/serialize.h b/src/serialize.h --- a/src/serialize.h +++ b/src/serialize.h @@ -575,23 +575,20 @@ return Wrapper(t); } -#define VARINT(obj, ...) WrapVarInt<__VA_ARGS__>(REF(obj)) +#define VARINT(obj, ...) Using>(obj) #define COMPACTSIZE(obj) CCompactSize(REF(obj)) #define LIMITED_STRING(obj, n) LimitedString(REF(obj)) -template class CVarInt { -protected: - I &n; - -public: - explicit CVarInt(I &nIn) : n(nIn) {} - - template void Serialize(Stream &s) const { - WriteVarInt(s, n); +/** + * Serialization wrapper class for integers in VarInt format. + */ +template struct VarIntFormatter { + template void Ser(Stream &s, I v) { + WriteVarInt::type>(s, v); } - template void Unserialize(Stream &s) { - n = ReadVarInt(s); + template void Unser(Stream &s, I &v) { + v = ReadVarInt::type>(s); } }; @@ -669,11 +666,6 @@ } }; -template -CVarInt WrapVarInt(I &n) { - return CVarInt{n}; -} - template BigEndian WrapBigEndian(I &n) { return BigEndian(n); }