How to serialize structs containing unions using the Cereal C++11 library?

32 Views Asked by At

How does the Cereal C++11 library handle unions within structs? For example:

enum class Tag { eInt, eFloat };

struct myStruct
{
    Tag tag;
    union
    {
        int i;
        float f;
    } val;

    // Cereal C++11 serialize function
    template <class Archive>
    void serialize(Archive& archive)
    {
        archive(tag, val); // is this correct?
    }
};
         
0

There are 0 best solutions below