Skip to content

Better documentation on when <cereal/types/polymorphic.hpp> is required #193

@johnwbyrd

Description

@johnwbyrd

I spent a few hours beating my head against a particular problem until the solution became clear, and I'd like to save the next guy the same time. In particular, I was trying to serialize something like the following structure:

std::map< int, std::shared_ptr< MySubclass > > myMap;

and I kept getting the following error:

cereal could not find any output serialization functions for the provided type and archive combination.

A serialization function existed and was working for MySubclass, so I couldn't see what all the fuss was about.

The actual source of the error, however, was that I had apparently failed to include cereal/types/polymorphic.hpp, and so myMap could not work out a specialization for MySubclass.

It would be helpful to both amend the documentation and the warning message to indicate that polymorphic.hpp needs to be included any time you serialize a derived class stored within a shared_ptr, regardless of whether or not there are multiple dependent serialized classes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions