#include "set"
void foo() {
set<int> myset;
myset.insert(0);
myset.insert(1);
myset.insert(3);
myset.insert(5);
myset.insert(100);
auto low = myset.lower_bound(2);
auto up = myset.upper_bound(4);
cout << "lower bound: " << *low << endl;
cout << "upper bound: " << *up << endl;
}
lower_bound和upper_bound函数用于在有序容器中查找某个值。lower_bound函数返回第一个大于或等于给定值的迭代器,upper_bound函数返回第一个大于给定值的迭代器。