STL newbie question:
Regarding functions std::map::upper_bound
and std::map::lower_bound
is it valid to specify a key that is not actually pres
Yes, they are both valid.
map::lower_bound returns an iterator pointing to the first element that is not less than key.
map::upper_bound returns an iterator pointing to the first element that is greater than key.
intmap[1]=10;
intmap[2]=20;
intmap[4]=40; // <<---both lower_bound(3)/upper_bound(3) will points to here
intmap[5]=50;
lower_bound/upper_bound
return the position where value would get inserted.
Note, If you want to check the value key is map or not, you could use std::map::find