C
Christopher
A developer before me created a large enumeration we can call
EnumType1.
He then, right under it, typedef-ed another
typedef EnumType1 EnumType2
He then created a comment "alias, should only include x types", where
x is a rule defining a subset of EnumType1
This is crap imo. Any function or method declared to take EnumType2,
would happily take a value from EnumType1 that does not meet the x
criteria.
Since I know the subset from EmunType1 that meets the x criteria, how
can I define a subset EnumType2 that only includes those enums without
typing the whole darn subset twice?
Example
enum Fruit
{
APPLE = 0,
BANANA,
ORANGE,
TANGERINE,
GRAPEFRUIT,
NUM_FRUITS
};
typedef Fruit Citrus; // This is crap and I want to fix it
EnumType1.
He then, right under it, typedef-ed another
typedef EnumType1 EnumType2
He then created a comment "alias, should only include x types", where
x is a rule defining a subset of EnumType1
This is crap imo. Any function or method declared to take EnumType2,
would happily take a value from EnumType1 that does not meet the x
criteria.
Since I know the subset from EmunType1 that meets the x criteria, how
can I define a subset EnumType2 that only includes those enums without
typing the whole darn subset twice?
Example
enum Fruit
{
APPLE = 0,
BANANA,
ORANGE,
TANGERINE,
GRAPEFRUIT,
NUM_FRUITS
};
typedef Fruit Citrus; // This is crap and I want to fix it