Victor Bazarov said:
There is no way. The enumerators are not members, they are not elements,
they are not objects, they don't occupy memory, so any _existing_ means
to find out sizes of different things in C++ do not work. And there is
no special enum-specific mechanism because nobody ever needed one.
Why do you think you need to know the number of those constants? And why
is it obvious that in your example it's 10? And why do you think you need
to know that number, yet can't hard-code it?
1) Since I need to create an array of objects.. one per token... for example
enum foo {Orange, Bannana, Apple}; foo Fruit["sizeof foo"]
2) In the example I gave it is clearly ten since it is using counting words
but that is besides the point here
3) It is for a system where new "tokens" can be added at compile time to the
enum and since we need the size to make the array and/or any associated
loops for the array need some "constant" that is the size of enum but do not
want to maintain two seperate values when 1 should do (the enum it self and
size
if derived)... doing it the other way is just asking for bugs in the lonbg
run.
--Aryeh