I have multimap<key_type,value_type>
, and I would like to know if a particular key will be displayed on the map no more than once.
I know that I can call multimap.equal_range(key)
to find an iterator for the beginning and end of the range containing key
, but I would like to know if there is only one element between range.first
and range.second
.
Is there a better way than incrementing the value of range.first
to see if it is equal to range.end
? Since multimap::iterator
is bidirectional, this is not a huge deal to undo the increment, but it seems messy for that.
source share