mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
NVP + traits changes
Added more NVP info to types that need it Adding ability to detect a save function (member or non-member) that is incorrectly declared as non-const. This is needed since some nasty compilation errors crop up if you explicitly specify a serialization type and register that type with an incorrectly constified save function. So not done yet, but soon in: using a non const save function will trigger a static assertion. Still need to investigate registering types with explicit disambiguation
This commit is contained in:
16
sandbox.cpp
16
sandbox.cpp
@@ -37,6 +37,9 @@
|
||||
#include <cereal/types/array.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
#include <cereal/types/map.hpp>
|
||||
#include <cereal/types/utility.hpp>
|
||||
#include <cereal/types/bitset.hpp>
|
||||
#include <cereal/types/polymorphic.hpp>
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <sstream>
|
||||
@@ -56,6 +59,8 @@ class Base
|
||||
ar( x );
|
||||
}
|
||||
|
||||
virtual void foo() = 0;
|
||||
|
||||
int x;
|
||||
};
|
||||
|
||||
@@ -78,15 +83,18 @@ class Derived : public Base
|
||||
ar( y );
|
||||
}
|
||||
|
||||
void foo() {}
|
||||
|
||||
int y;
|
||||
};
|
||||
|
||||
namespace cereal
|
||||
{
|
||||
template <class Archive> struct specialize<Archive, Derived, cereal::specialization::member_load_save> {};
|
||||
//template <class Archive> struct specialize<Archive, Derived, cereal::specialization::non_member_load_save> {};
|
||||
}
|
||||
|
||||
CEREAL_REGISTER_TYPE(Derived);
|
||||
|
||||
// ###################################
|
||||
struct Test1
|
||||
{
|
||||
@@ -213,7 +221,7 @@ struct Everything
|
||||
struct EmptyStruct
|
||||
{
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar)
|
||||
void serialize(Archive &)
|
||||
{
|
||||
std::cout << "Side effects!" << std::endl;
|
||||
};
|
||||
@@ -233,7 +241,7 @@ struct NoDefaultCtor
|
||||
int y;
|
||||
|
||||
template <class Archive>
|
||||
void serialize( Archive & archive )
|
||||
void serialize( Archive & )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -250,7 +258,7 @@ namespace cereal
|
||||
struct LoadAndAllocate<NoDefaultCtor>
|
||||
{
|
||||
template <class Archive>
|
||||
static NoDefaultCtor * load_and_allocate( Archive & ar )
|
||||
static NoDefaultCtor * load_and_allocate( Archive & )
|
||||
{
|
||||
return new NoDefaultCtor(5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user