serialization: teach serializers variadics

Also add a variadic CDataStream ctor for ease-of-use.
This commit is contained in:
Cory Fields
2018-04-16 07:38:37 -06:00
committed by Jack Grigg
parent ead36d85c7
commit d1c9ef8606
3 changed files with 130 additions and 0 deletions
+11
View File
@@ -80,6 +80,13 @@ public:
Init(nTypeIn, nVersionIn);
}
template <typename... Args>
CBaseDataStream(int nTypeIn, int nVersionIn, Args&&... args)
{
Init(nTypeIn, nVersionIn);
::SerializeMany(*this, nType, nVersion, std::forward<Args>(args)...);
}
void Init(int nTypeIn, int nVersionIn)
{
nReadPos = 0;
@@ -323,6 +330,10 @@ public:
CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) :
CBaseDataStream(vchIn, nTypeIn, nVersionIn) { }
template <typename... Args>
CDataStream(int nTypeIn, int nVersionIn, Args&&... args) :
CBaseDataStream(nTypeIn, nVersionIn, args...) { }
};