I tried to use the lowerbound() in C++ STL Map. Before I use it, I test its functionality through a program like below:
int main () { std::map<int,int> mymap; std::map<int,int>::iterator itlow; mymap[1]=20; mymap[3]=60; mymap[4]=80; mymap[5]=100; itlow=mymap.lower_bound (2); //Test1 std::cout<<(--itlow)->first<<'\n'; //print 1 std::cout<<itlow->second<<'\n'; //print 20 //Test2 std::cout<<(--itlow)->first<<": "<<itlow->second<<'\n'; //print 1 : 60 } I tested 1 and 2 separately which means when I tested 1, I commented Test2 and same as reverse. Test 1's result is under my expectation, but I don't understand why Test2 print 60 for the second field instead of 20?
print 1 : 60is probably a comment.