Multimap has the important property that inserting a new element
into a multimap does not invalidate iterators that point to existing
elements. Erasing an element from a set also does not invalidate
any iterators, except, of course, for iterators that actually point
to the element that is being erased.

Definition

Defined in the standard header map, and in the nonstandard
backward-compatibility header multimap.h.

Template parameters

Parameter

Description

Default

Key

The multimap's key type. This is also defined as multimap::key_type.

Data

The multimap's data type. This is also defined as multimap::data_type.

Compare

The key comparison function, a Strict Weak Ordering whose
argument type is key_type; it returns true if its first
argument is less than its second argument, and false otherwise.
This is also defined as multimap::key_compare.

New members

Notes

[1]Multimap::iterator is not a mutable iterator, because
multimap::value_type is not
Assignable. That is, if i is of
type multimap::iterator and p is of type
multimap::value_type, then *i = p is not a valid
expression. However, multimap::iterator isn't a constant
iterator either, because it can be used to modify the object that it
points to. Using the same notation as above, (*i).second = p
is a valid expression. The same point applies to
multimap::reverse_iterator.

[2]
This member function relies on member template functions, which
at present (early 1998) are not supported by all compilers. If your
compiler supports member templates, you can call this function with
any type of input iterator. If your
compiler does not yet support member templates, though, then the
arguments must either be of type const value_type* or of type
multimap::const_iterator.