#include
using namespace std;
int main()
{
vector>v;
v.push_back(ma
The comparator used uses both values in the pairs when doing the comparison.
It compares lhs and rhs lexicographically by operator<
(operator<=>
since C++20), that is, compares the first elements and only if they are equivalent, compares the second elements.
If I write the comparator function, then it is working properly
That's because you've probably implemented it like this:
[](const auto& lhs, const auto& rhs) {
return lhs.first < rhs.first;
}
The default comparator does something equivalent to this:
[](const auto& lhs, const auto& rhs) {
return lhs.first == rhs.first ? lhs.second < rhs.second : lhs.first < rhs.first;
}