Is there a way to fetch the number of elements in an enum
in C++11 at compile time? In my case the enum
is a ordered bitmask enum, meaning that first element is 0x0000
, next element is 0x0001
and so on.
Asked
Active
Viewed 78 times
0

nyarlathotep108
- 5,275
- 2
- 26
- 64
-
1scoped or unscoped enum? – 463035818_is_not_an_ai Feb 01 '19 at 15:02
-
1Often, one just adds an extra member to the enum, named `Count` or something. – Igor Tandetnik Feb 01 '19 at 15:06
-
@user463035818 unscoped enum – nyarlathotep108 Feb 01 '19 at 15:09
-
the duplicate is not specifically asking for compile time, but the answers apply. – 463035818_is_not_an_ai Feb 01 '19 at 15:10