Minimal serialization with vectors
mandryskowski opened this issue · 0 comments
mandryskowski commented
#include <cereal/access.hpp>
#include <cereal/types/vector.hpp>
#include <cereal/archives/json.hpp>
class Minimal
{
public:
Minimal() : IDVal(0) {}
Minimal(uint64_t id) : IDVal(id) {}
bool operator==(const Minimal& rhs) const { return rhs.IDVal == IDVal; }
uint64_t GetValue() const { return IDVal; }
// Cereal serialization methods
template <typename Archive>
uint64_t save_minimal(const Archive& archive) const
{
return IDVal;
}
template <typename Archive>
void load_minimal(const Archive& archive, const uint64_t& id)
{
IDVal = id;
}
private:
uint64_t IDVal;
};
int main()
{
cereal::JSONOutputArchive out(std::cout);
std::vector<Minimal> vec = { 1, 2, 3, 4 };
out(vec);
return 0;
}
Trying to compile this code causes the "cereal could not find any output serialization functions for the provided type and archive combination." static assertion to fail. The same happens with load_minimal when I use an input archive.
Was it a deliberate choice to forbid minimal serialization with vectors?