lundi 10 février 2020

Is it possible to prevent omission of aggregate initialization members?

I have a struct with many members of the same type, like this

struct VariablePointers {
   VariablePtr active;
   VariablePtr wasactive;
   VariablePtr filename;
};

And I forgot to initialize filename, instead it went like this:

VariablePointers{activePtr, filename}

How can I prevent this kind of error? I could add a constructor, but it would duplicate the list of variable twice, so I have to type all of this thrice!

Aucun commentaire:

Enregistrer un commentaire