I want to get a key-val pair from map a which key is less than or equal to a given K. I want to get end (or rend or any error indication) that So simple code and nearly same:
#include <iostream>
#include <map>
using namespace std;
int main() {
map<int, int> m;
m[56]= 666;
auto it = m.lower_bound(1);
if(it != m.end()) {
cout << it->first;
} else {
cout << "this was expected!=(";
}
return 0;
}
I get same bad result for lower_bound and upper_bound. What do I do wrong?