#include <iostream>
#include <map>
int main() {
std::map<int, std::string, std::greater<int>> myMap;
myMap.insert(std::make_pair(20, "twenty"));
myMap.insert(std::make_pair(15, "fifteen"));
myMap.insert(std::make_pair(10, "ten"));
myMap.insert(std::make_pair(5, "five"));
auto it = myMap.lower_bound(5);
if (it != myMap.end()) {
std::cout << "Found: " << it->second << std::endl;
} else {
std::cout << "Not found!" << std::endl;
}
return 0;
}
?std::map<int, std::string, std::greater<int>> myMap;??lower_bound : 返回第一个不大于的元素
若传入0, 输出 not found ,因为没有不大于0的值