Namespaces
Variants
Actions

C++ named requirements: AssociativeContainer

From cppreference.com
< cpp‎ | named req
 
 
C++ named requirements
 

An AssociativeContainer is an ordered Container that provides fast lookup of objects based on keys.

An associative container supports unique keys if it may contain at most one element for each key. Otherwise, it supports equivalent keys.

Contents

[edit] Requirements

Legend
X An associative container class
T The element type of X
A The allocator type of X: X::allocator_type if it exists, otherwise std::allocator<X::value_type>
a A value of type X
a2 A value of a type Y whose node handles are compatible with X
b A value of type X or const X
u A name of a variable beging declared
a_uniq A value of type X when X supports unique keys
a_eq A value of type X when X supports equivalent keys
a_tran A value of type X or const X when type X::key_compare::is_transparent exists
i, j The LegacyInputIterators referring to elements implicitly convertible to X::value_type
[ij) A valid range
rg
(since C++23)
A value of a type R that models container-compatible-range<value_type>
p A valid constant iterator to a
q A valid dereferenceable constant iterator to a
r A valid dereferenceable iterator to a
q1, q2 A valid range of const iterators in a
il An object of type std::initializer_list<X::value_type>
t A value of type X::value_type
k A value of type X::key_type
c A value of type X::key_compare or const X::key_compare
kl A value such that a is partitioned with respect to c(x, kl), with x the key value of e and e in a
ku A value such that a is partitioned with respect to !c(ku, x), with x the key value of e and e in a
ke A value such that a is partitioned with respect to c(x, ke) and !c(ke, x), with c(x, ke) implying !c(ke, x) and with x the key value of e and e in a
kx
(since C++23)
A value such that:
  • a is partitioned with respect to c(x, kx) and !c(kx, x), with c(x, kx) implying !c(kx, x) and with x the key value of e and e in a, and
  • kx is not convertible to either X::iterator or X::const_iterator
m An allocator of a type convertible to A
nh A non-const rvalue of type X::node_type

The type X satisfies AssociativeContainer if

  • The type X satisfies Container(until C++11)AllocatorAwareContainer(since C++11),
  • Is parameterized on Key and an ordering relation Compare that induces a strict weak ordering on elements of Key, and
    • In addition, std::map and std::multimap associate an arbitrary mapped type T with the Key.
    • The object of type Compare is called the comparison object of a container of type X.
  • The following expressions must be valid and have their specified effects for all associative containers:

[edit] Types

Name Type Requirements
key_type Key
mapped_type T (for std::map and std::multimap only)
value_type Erasable from X
key_compare Compare CopyConstructible
value_compare
  • same as key_compare (for