【发布时间】:2019-10-16 12:57:22
【问题描述】:
我想在地图中(在一个范围内)找到我的目标的下界。
我知道另一种解决方案:
int main() {
map<int,int> m;
auto it=m.lower_bound(10);
cout<<it->first<<" "<<it->second<<endl;
return 0;
}
但是,我想知道如何使用std::lower_bound(m.begin(),m.end(),***)。
int main() {
map<int,int> m;
auto it=std::lower_bound(m.begin(),m.end(),10);
cout<<it->first<<" "<<it->second<<endl;
return 0;
}
main.cpp:29:43: 从这里需要 /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/bits/predefined_ops.h:65:22:错误:'operator
【问题讨论】:
-
不清楚范围是多少?
-
问题是
m.begin()是一个指向一对的迭代器。您不能比较整数值的对。
标签: c++ stl lower-bound