I would like to create a composite type out of two enum classes.
enum classes
enum class Color {RED, GREEN, BLUE}; enum class Shape {SQUARE, CIRCLE, TRIANGLE};
You only need to compare shape if color is the same for both.
shape
color
Using a ternary you can make it look nice too:
friend bool operator< (const Object &lhs, const Object &rhs) { return lhs.color == rhs.color ? (lhs.shape < rhs.shape) : (lhs.color < rhs.color); }