C++ 杂疑难点记录

STL类

Comparator需要follow strict weak order.

bool compare(vector<int> &a,vector<int> &b){
          return a[1]<=b[1];
}

should be

bool compare(const vector<int> &a, const vector<int> &b){
          return a[1]<b[1];
}

Comparators must define a strict weak ordering. One consequence of that is that they must return false for equal values, so <= is incorrect.

Tags: none

New Comment