> static const int DEFAULT_VALUE = 0;
Make this
static const T DEFAULT_VALUE = T();
> if ((newFirst == second) && (newFirst != 0))
> if ((newSecond == first) && (newSecond != 0))
Change the 0 to be DEFAULT_VALUE
1 2 3
|
bool operator<(const OrderedPair<T>& right) const {
return first + second < right.first + right.second;
}
|
I suppose it depends on what you mean by order
To me,
0 x will always come before
1 y regardless of the values of x and y
Whereas you're suggesting that
0 99 comes after
1 2
If you want to use this with strings, you need to construct your < operator to work only in terms of < on the sub-types.
Otherwise, it's a messy "what does it mean to add two strings and then compare them".