mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
const_cast for save(), seeking for binary_oarchive
Using const cast to get rid of having two versions of save (changed vector and array so far) Initial implementation of seeking to allow saving and restoring position within a binary archive
This commit is contained in:
@@ -26,11 +26,11 @@ std::ostream& operator<<(std::ostream& os, StructBase const & s)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct StructInternalSerialize : StructBase
|
||||
{
|
||||
StructInternalSerialize() : StructBase{0,0} {}
|
||||
StructInternalSerialize(int x_, int y_) : StructBase{x_,y_} {}
|
||||
StructInternalSerialize(int x_, int y_) : StructBase{x_,y_} {}
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar)
|
||||
{
|
||||
@@ -41,9 +41,9 @@ struct StructInternalSerialize : StructBase
|
||||
struct StructInternalSplit : StructBase
|
||||
{
|
||||
StructInternalSplit() : StructBase{0,0} {}
|
||||
StructInternalSplit(int x_, int y_) : StructBase{x_,y_} {}
|
||||
StructInternalSplit(int x_, int y_) : StructBase{x_,y_} {}
|
||||
template<class Archive>
|
||||
void save(Archive & ar)
|
||||
void save(Archive & ar) const
|
||||
{
|
||||
ar & x & y;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ struct StructInternalSplit : StructBase
|
||||
struct StructExternalSerialize : StructBase
|
||||
{
|
||||
StructExternalSerialize() : StructBase{0,0} {}
|
||||
StructExternalSerialize(int x_, int y_) : StructBase{x_,y_} {}
|
||||
StructExternalSerialize(int x_, int y_) : StructBase{x_,y_} {}
|
||||
};
|
||||
|
||||
template<class Archive>
|
||||
@@ -70,11 +70,11 @@ void serialize(Archive & ar, StructExternalSerialize & s)
|
||||
struct StructExternalSplit : StructBase
|
||||
{
|
||||
StructExternalSplit() : StructBase{0,0} {}
|
||||
StructExternalSplit(int x_, int y_) : StructBase{x_,y_} {}
|
||||
StructExternalSplit(int x_, int y_) : StructBase{x_,y_} {}
|
||||
};
|
||||
|
||||
template<class Archive>
|
||||
void save(Archive & ar, StructExternalSplit & s)
|
||||
void save(Archive & ar, StructExternalSplit const & s)
|
||||
{
|
||||
ar & s.x & s.y;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE( structs )
|
||||
StructExternalSplit i_espl;
|
||||
|
||||
iar & i_iser & i_ispl & i_eser & i_espl;
|
||||
|
||||
|
||||
BOOST_CHECK(i_iser == o_iser);
|
||||
BOOST_CHECK(i_ispl == o_ispl);
|
||||
BOOST_CHECK(i_eser == o_eser);
|
||||
|
||||
Reference in New Issue
Block a user