mardi 6 septembre 2016

Brace initializers for structs with default values

Initializing a struct with default values is trivial:

struct X { int a; int b = 2; };

and initializing a struct with a brace initializer is trivial too:

X x = {1, 3};

Suprisingly the init code won't compile, until I remove the default value. So, how would I do the init in such a case? I'd like to keep X a POD without c-tor.

Aucun commentaire:

Enregistrer un commentaire