How to generalize the definition of < if the struct has arbitrarily many data members (< is to be defined using the order in which the data members are listed)? A simple example with 3 data members:
struct nData {
int a;
double b;
CustomClass c; // with == and < defined for CustomClass
bool operator == (const nData& other) {return (a == other.a) && (b == other.b) && (c == other.c);}
bool operator < (const nData& other) {
if ( (a < other.a) || ((a == other.a) && (b < other.b)) ||
((a == other.a) && (b == other.b) && (c < other.c)) )
return true;
return false;
}
};
Using variadic templates and recursion somehow?