[flat.multimap.overview] (original) (raw)

23 Containers library [containers]

23.6 Container adaptors [container.adaptors]

23.6.9 Class template flat_multimap [flat.multimap]

23.6.9.1 Overview [flat.multimap.overview]

A flat_multimap is a container adaptor that provides an associative container interface that supports equivalent keys (i.e., possibly containing multiple copies of the same key value) and provides for fast retrieval of values of another type Tbased on the keys.

flat_multimap meets the requirements of an associative container ([associative.reqmts]), except that:

[Note 1:

A flat_multimap does not meet the additional requirements of an allocator-aware container ([container.alloc.reqmts]).

— _end note_]

A flat_multimap also provides most operations described in [associative.reqmts] for equal keys.

This means that a flat_multimap supports the a_eq operations in [associative.reqmts]but not the a_uniq operations.

For a flat_multimap<Key, T>the key_type is Key and the value_type is pair<Key, T>.

Except as otherwise noted, operations on flat_multimap are equivalent to those of flat_map, except that flat_multimap operations do not remove or replace elements with equal keys.

[Example 1:

flat_multimap constructors and emplace do not erase non-unique elements after sorting them.

— _end example_]

A flat_multimap maintains the following invariants:

If any member function in [flat.multimap.defn] exits via an exception, the invariants are restored.

[Note 2:

This can result in the flat_multimap being emptied.

— _end note_]

Any type Cthat meets the sequence container requirements ([sequence.reqmts]) can be used to instantiate flat_multimap, as long asC​::​iterator meets the Cpp17RandomAccessIterator requirements and invocations of member functions C​::​size and C​::​max_size do not exit via an exception.

In particular,vector ([vector]) and deque ([deque]) can be used.

[Note 3:

vector<bool> is not a sequence container.

— _end note_]

The program is ill-formed ifKey is not the same type as KeyContainer​::​value_type orT is not the same type as MappedContainer​::​value_type.

The effect of calling a constructor that takes both key_container_type andmapped_container_type arguments with containers of different sizes is undefined.

The effect of calling a constructor or member function that takes a sorted_equivalent_t argument with a container, containers, or range that are not sorted with respect to key_comp() is undefined.