I have a multimap<key_type,value_type> and I would like to know if a particular key appears in the map at most one time.
I know I can call multimap.equal_range(key) to find an iterator to the start and end of the range containing key but I would like to know if there is only one element between the range.first and range.second.
Is there a better way than incrementing the range.first value to see if it is equal to range.end? Since multimap::iterator is bidirectional it’s not a huge deal to undo the increment but it seems sloppy to do that.
Could you check if the std::multimap::count(key) == 1?