-
Anonymous
Как перебирать перечисление с помощью цикла с диапазоном [дубликат]
Сообщение
Anonymous »
Код: Выделить всё
#define DEFINE_ENUM_CLASS(Name, ...) \
enum class Name { __VA_ARGS__ }; \
constexpr const char* Name##Strings[] = { #__VA_ARGS__ };
int main()
{
DEFINE_ENUM_CLASS(Color, Red, Green, Blue);
DEFINE_ENUM_CLASS(Bolor, Blue, Cyan, Green);
for (const char* colorName : ColorStrings)
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78988452/how-to-iterate-over-an-enumeration-with-a-ranged-for-loop[/url]
1726456139
Anonymous
[code]#define DEFINE_ENUM_CLASS(Name, ...) \
enum class Name { __VA_ARGS__ }; \
constexpr const char* Name##Strings[] = { #__VA_ARGS__ };
int main()
{
DEFINE_ENUM_CLASS(Color, Red, Green, Blue);
DEFINE_ENUM_CLASS(Bolor, Blue, Cyan, Green);
for (const char* colorName : ColorStrings)
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78988452/how-to-iterate-over-an-enumeration-with-a-ranged-for-loop[/url]