mardi 28 janvier 2020

wrapper to make anonymous enums proper types

I have some typedef'd enums that are included from c-code, i,e. they are available in the form
typedef enum {FOO=3, BAR=5} my_enum; and I would like use it in C++ code in a typesafe manner while leaving the enum names (FOO and BAR) and values (3 and 5) and their association unmodified.

Are there any best practices or patterns like template wrappers, that can be recommended to accomplish that, say in C++11 or higher?

Aucun commentaire:

Enregistrer un commentaire