I have an old C library and I have to wrap it inside a C++ environment. I use C++11 enum class
because they're so useful and I'd like to do transform the original enum
into a new enum class
without simply create the new enum class
and rewriting it. I'd like to do something like a typedef
as in the old C:
enum num_oldc
{
one,
two,
three
};
typedef enum num_oldc num_oldc_t;
But one_t
must be accessible via its scope num_t::two
exactly in the same way I can access a new C++11 enum class
.
You won't be able to do this with a
typedef
. However, you can do it as follows.enum class
with entries that correspond to the entries of your C-styleenum
.enum class
and the C-styleenum
.enum class
.enum
whenever you need to interface with the library you are wrapping.