我有一個std :: multimap其中key是一個自定義類。事情是這樣的:關鍵在std :: multimap的要求
Class X {
public:
std::string s;
int x;
operator <(const X& other) const { return s < other.s; }
};
std::multimap<X, int> mymap;
現在,我想使用UPPER_BOUND和LOWER_BOUND遍歷以「S」的相同值的所有元素。我是否需要爲X實現一些其他運算符(例如:==)。或者它會像這樣正常工作?
而且,我應該提供的論據UPPER_BOUND和LOWER_BOUND?我假設我應該創建一個期望值爲「s」的虛擬對象?
您不需要提供運算符==()。 – 2008-10-18 23:14:33