Smart enumerations.
A method of declaring a user type that also contains a set of constants, but are not constrained to just those values. This contrasts with 'enum_type', where the values are expected to only contain those defined as constants. Declaring the enumeration.
ETL_DECLARE_USER_TYPE(CompassDirection, int)
ETL_USER_TYPE(North, 0)
ETL_USER_TYPE(South, 180)
ETL_USER_TYPE(East, 90)
ETL_USER_TYPE(West, 270)
ETL_END_USER_TYPE(CompassDirection)
Using the enumeration.
CompassDirection direction;
direction = CompassDirection::North;
int value = int(direction);
int value = direction.get();
int& value = direction.get();
const int& value = direction.get();
direction = CompassDirection(value);
direction = CompassDirection(3);
++direction;
direction -= CompassDirection(20);
direction = value;