equal-range

std::equal_range not working with strucutre having operator< defined

荒凉一梦 提交于 2019-12-10 18:29:47
问题 I am trying to use std::equal_range with the structure below I have compilation error saying that error: no match for ‘operator<’ . struct MyFoo { int v_; string n_; bool operator<(int v) const { return v_ < v;} }; vector<MyFoo> data; // data is sorted by int v_ typedef vector<MyFoo>::iterator Ptr; std::pair< Ptr, Ptr > pr = std::equal_range(data.begin(), data.end(), 10); I've looked into the template implementatino and what is failing is the following where *it is deferenging the iterator