As the other answers explain, for a std::map
you can use find
.
To answer the question in the headline:
For iterators, const
can refer to the iterator itself, or the to the contents, the iterator points to. Both properties are orthogonal. With STL notation you have the following cases:
iterator
Contents and iterator can be modified.
const_iterator
Contents is const, the iterator can be modified
const iterator
Contents can be modified, the iterator is const.
const const_iterator
Contents and iterator are constant.
It is similar for pointers. There, the const can also refer to the contents or the pointer itself.