Possible Duplicate:
(How) can I count the items in an enum?
Is there a way to get the number of constants in enum?
For example:
enum C{id,value};
And later this would return 2:
//pseudo code
get<C>::value
And also, is it possible to access those constants via [] optor? Like i.e.:
C[0] would return id
Usually, you start at zero and the last member gives the size of the enum excluding it.
C::sizeis the size of the enum. Is it possible to access those constants via subscript? No, it is unfortunately most assuredly not possible. However, in this case, you don’t really want an enum- you just want a constant array.