과부하를 걸고 <
(이하) 비교기를 정수 쌍의 집합으로 전달하는 방법을 알고 싶습니다.페어 세트에 대한 비교 연산자를 오버로드하는 방법은 무엇입니까?
class A{
public:
typedef std::pair<int, int> pair_type;
bool operator<(const pair_type& a, const pair_type& b){
if (a.first < b.first) return true;
else if ((a.first == b.first) && (a.second < b.second)) return true;
else return false;
}
private:
std::set<pair_type> edge_;
};
이 오류가 발생합니다. 어떻게 해결할 수 있습니까?
error: 'bool A::operator<(const pair_type&, const pair_type&)' must take exactly one argument
는 '표준 : pair' 이미 [적정을 갖는다 operator <] (http://en.cppreference.com/w/cpp/utility/pair/operator_cmp)를 참조하십시오. – Mankarse