mardi 4 août 2020

unified view to slightly different structs

I have a complicated structs that evolved from version to version, adding/removing fields. For backward compatibility, all the versions are kept in the code, leading to something like this :

struct MyDataV0{
    int a;
    .....
};
struct MyDataV1{
    //int a disappeared for this version
    double d; //this fields was added to this version
    .....
};

I want to provide a unified view of this struct that is version agnostic. Is there a pattern or best practices to do this?

Aucun commentaire:

Enregistrer un commentaire