Nope.
If that were the case, you would not see as much code as this:
enum E { VALUE_BLAH, VALUE_OTHERBLAH, ... VALUE_FINALBLAH, VALUE_COUNT }
Note that this code is also a hint for a (unpleasant) solution - if you add the last "guard" element and do not explicitly specify the enum fields, then the last "COUNT" element will have the value you are looking for - this is because enumeration counter is based on a zero value:
enum B { ONE, // has value = 0 TWO, // has value = 1 THREE, // has value = 2 COUNT // has value = 3 - cardinality of enum without COUNT }
Kornel kisielewicz
source share