Multiple calls to Archive::operator()

22 views
Skip to first unread message

Theodoros Theodoridis

unread,
Apr 8, 2020, 5:46:24 AM4/8/20
to cereal serialization library
Hello

Is the following behavior supported?

struct MyClass
{
 
int x, y, z;

 
template<class Archive>
 
void serialize(Archive & archive)
 
{
    archive
( x );
    archive
( y );
    archive
( z );
 
}
};

If it is, would the following code work?

struct MyClass
{
 
int x, y, z;

 
template<class Archive>
 
void save(Archive & archive) const
 
{
    archive
( x );
   
if (x > 0)
      archive
( y, z );
 
}

 
template<class Archive>
 
void load(Archive & archive)
 
{
    archive
( x );
   
if (x > 0)
    archive
( y, z );
 
}
};

Thanks,
Theo

Reply all
Reply to author
Forward
0 new messages