Is it possible to determine the number of elements of a c++ enum class?

后端 未结 13 1815
长情又很酷
长情又很酷 2020-12-13 01:39

Is it possible to determine the cardinality of a c++ enum class:

enum class Example { A, B, C, D, E };

I tried to use si

13条回答
  •  悲哀的现实
    2020-12-13 02:02

    One trick you can try is to add a enum value at the end of your list and use that as the size. In your example

    enum class Example { A, B, C, D, E, ExampleCount };
    

提交回复
热议问题