A third party library has structs defined as
typedef struct _Example
{
int member;
} Example;
As a side question, just out of interest, why that definition? Why not struct Example { ... }?
Anyhow, I want to serialize the information with boost::serialization, and for that need a constructor. Is it safe to just change my version of the 3rd party header file by adding a constructor to the struct definition? Or alternatively, to just copy that definition to my own code base, rename it, add a constructor, and reinterpret_cast to it?
I assume it would be because as I understand functions and constructors shouldn’t change the underlying byte layout of the class/struct, is this correct?
Thanks
Your struct has a constructor. Compiler generated for you a no-arg constructor and thats exactly what boost::serialization needs.