std::map find/end both provides const_iterator and iterator, e.g.
iterator end ();
const_iterator end () const
Out of curiosity,if I have a std::map , which will be called/compared here, an iterator or a const_iterator ? :
if(m.find(key) != m.end()) {
...
}
And should I care ?
If
misconst, then aconst_iteratorwill be returned; otherwise aniteratorwill be returned.If all you are doing is testing for existence of an element in the map, then it doesn’t really matter which one is used.