C++ still doesn't have the ability to count the number of items in an enumeration. There are various workarounds, but they are primarily hacks with serious drawbacks:
enum Information
{
MIN = 0,
NAME = MIN,
ADDRESS,
BIRTHDATE,
Count
};
int NumOfElements = Count; // only works items sequential
My understand is that enums are evaluated and substituted at compile time. What I don't understand is why the compiler can't count the number of enum members, like so:
#define INFO_COUNT = #COUNT_MEMBERS(Information)
int NumOfElement = INFO_COUNT; // NumOfElements is 5
Is there something I am missing? Is there a gotcha lurking somewhere?