How do I find if I have any keys within a range . I am trying below:
The goal is to get -2 and 2
as the key boundary range (that actually exists in the map) within enquiry range [-3,3]
std::map<int, char> m{ {-2,'B'}, {1, 'C'}, {2, 'A'}};
auto itCurrent = m.lower_bound(-3);
auto itNext = m.upper_bound(-3);
auto it1 = m.lower_bound(3);
auto it2 = m.upper_bound(3);
I do get value -2
for itCurrent
and itNext
but why am I getting end
for it1
and it2
both. I was expecting m.lower_bound(3)
should return 2
.