I want to create an enum with 255 elements as follows:
enum class MyEnum
{
Item0,
Item1,
//....
Item254,
Item255
};
Is there any way to generate the members of the enum using a macro instead of actually listing them all?
I want to create an enum with 255 elements as follows:
enum class MyEnum
{
Item0,
Item1,
//....
Item254,
Item255
};
Is there any way to generate the members of the enum using a macro instead of actually listing them all?
Well, it seems what the OP is after is BOOST_PP_ENUM_PARAMS
. I won't say it's the best solution, but it does work for an enum with values like these:
enum class MyEnum {
BOOST_PP_ENUM_PARAMS(256, Item)
};
you might use shell script to generate them...i think they won't change often
echo Item{0..255},