Consider implementing operator<
for the following class:
struct foo {
int a, b;
};
Probably the most common way is something like the element-wise lexicographic compare, like so:
bool operator<(foo lhs, foo rhs) {
return lhs.a < rhs.a || (lhs.a == rhs.a && lhs.b < rhs.b);
}
I've written that enough times, and made a type enough times that I'm wondering if there is something built in to std::
that will do it for me, hopefully with less boilerplate and reasonable code generation.
Now the above for two elements isn't that bad, but the terms multiply as you add more members.