Edit: The question title was based on a deep missunderstanding of the compiler error I got. I was (sillyly) assuming the error was, that I tried to deserialize to an object I declared inside of the function. This was utterly wrong. I didn't do enough debug efforts myself or I could have found out what was wrong. So the title was quite missleading and I changed it. Thanks to Андрей Беньковский for helping.
I'm writing Serialization functions for 3D Models in my engine using cereal, which proves to be really efficient and easy to use. So far everything worked great when I tested (de-)serializing a simple Mesh. But now I'm trying to deserialize another class but ran in a problem I don't get.
void loadFile(std::string filepath)
{
DescriptionFile file;
{
ifstream stream = ifstream(filepath, std::ifstream::binary);
PortableBinaryInputArchive archive(stream);
archive(file);
stream.close();
}
}
This is my class, that should be deserialized:
struct DescriptionFile
{
public:
DescriptionFile(){}
map<string, MeshDescription*> meshDescriptions;
map<string, ModelDescription*> modelDescriptions;
public:
template<class Archive>
void serialize(Archive & archive)
{
archive(meshDescriptions, modelDescriptions);
}
};
It gives me compiler error: Cereal does not support serializing raw pointers - please use a smart pointer Even though it's not a pointer. In another part of the code something similar works just fine. I'd be glad if somebody could help me solve this.
filepath
isstd::string
? Please edit your question to indicate the type. – Superiority