std::flat_multiset
<flat_set>
class Key,
class Compare = std::less <Key>,
class KeyContainer = std::vector <Key>
The flat multiset is a container adaptor that gives the functionality of an associative container that stores a sorted set of objects of type Key. Unlike std::flat_set, multiple keys with equivalent values are allowed. Sorting is done using the key comparison function Compare.
The class template flat_multiset acts as a wrapper to the underlying sorted container passed as object of type KeyContainer.
Everywhere the standard library uses the Compare requirements, uniqueness is determined by using the equivalence relation. Informally, two objects a and b are considered equivalent if neither compares less than the other: !comp(a, b) && !comp(b, a).
std::flat_multiset meets the requirements of Container, ReversibleContainer, optional container requirements, and all requirements of AssociativeContainer (including logarithmic search complexity), except that:
- requirements related to nodes are not applicable,
- iterator invalidation requirements differ,
- the complexity of insertion and erasure operations is linear.
A flat multiset supports most AssociativeContainer's operations that use equal keys.
std::flat_multiset are constexpr: it is possible to create and use std::flat_multiset objects in the evaluation of a constant expression.However, std::flat_multiset objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression.
Contents
[edit] Iterator invalidation
[edit] Template parameters
Key is not the same type as KeyContainer::value_type.
random_access_iterator.
The standard containers std::vector and std::deque satisfy these requirements.
[edit] Member types
iterator
implementation-defined LegacyRandomAccessIterator , ConstexprIterator (since C++26) and random_access_iterator to value_type[edit]
const_iterator
implementation-defined LegacyRandomAccessIterator , ConstexprIterator (since C++26) and random_access_iterator to const value_type[edit]
[edit] Member objects
container_type c (private)
the adapted container(exposition-only member object*)
key_compare compare (private)
the comparison function object(exposition-only member object*)
[edit] Member functions
(public member function)
Iterators
Capacity
Modifiers
Lookup
(public member function) [edit]
Observers
value_type (public member function) [edit]
[edit] Non-member functions
[edit] Helper classes
[edit] Tags
[edit] Deduction guides
[edit] Notes
The member types iterator and const_iterator may be aliases to the same type. This means defining a pair of function overloads using the two types as parameter types may violate the One Definition Rule. Since iterator is convertible to const_iterator, a single function with a const_iterator as parameter type will work instead.
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_flat_set |
202207L |
(C++23) | std::flat_set and std::flat_multiset
|
__cpp_lib_constexpr_flat_set |
202502L |
(C++26) | constexpr std::flat_multiset
|
[edit] Example
Reason: no example
[edit] See also
(class template) [edit]