|
|
|
of *this. Iterators referring to the moved elements will continue to refer to their elements, but they
now behave as iterators into *this, not into x.
13
Throws: Nothing.
14
Complexity: Constant time if &x == this; otherwise, linear time.
void remove(const T& value);
template<class Predicate> void remove_if(Predicate pred);
15
Effects: Erases all the elements in the list referred by a list iterator i for which the following conditions
hold: *i == value, pred(*i) != false. Invalidates only the iterators and references to the erased
elements.
16
Throws: Nothing unless an exception is thrown by *i == value or pred(*i) != false.
17
Remarks: Stable (20.5.5.7).
18
Complexity: Exactly size() applications of the corresponding predicate.
void unique();
template<class BinaryPredicate> void unique(BinaryPredicate binary_pred);
19
Effects: Erases all but the first element from every consecutive group of equal elements referred to by
the iterator i in the range [first + 1, last) for which *i == *(i-1) (for the version of unique
with no arguments) or pred(*i, *(i - 1)) (for the version of unique with a predicate argument)
holds. Invalidates only the iterators and references to the erased elements.
20
Throws: Nothing unless an exception is thrown by *i == *(i-1) or pred(*i, *(i - 1))
21
Complexity: If the range [first, last) is not empty, exactly (last - first) - 1 applications of
the corresponding predicate, otherwise no applications of the predicate.
void merge(list& x);
void merge(list&& x);
template<class Compare> void merge(list& x, Compare comp);
template<class Compare> void merge(list&& x, Compare comp);
22
Requires: Both the list and the argument list shall be sorted with respect to the comparator operator<
(for the first two overloads) or comp (for the last two overloads).
23
Effects: If (&x
== this) does nothing; otherwise, merges the two sorted ranges [begin(), end()) and
[x.begin(), x.end()). The result is a range in which the elements will be sorted in non-decreasing
order according to the ordering defined by comp; that is, for every iterator i, in the range other than the
first, the condition comp(*i, *(i - 1)) will be false. Pointers and references to the moved elements
of x now refer to those same elements but as members of *this. Iterators referring to the moved
elements will continue to refer to their elements, but they now behave as iterators into *this, not into
x.
24
Remarks: Stable (20.5.5.7). If (&x != this) the range [x.begin(), x.end()) is empty after the
merge. No elements are copied by this operation. The behavior is undefined if get_allocator() !=
x.get_allocator().
25
Complexity: At most size() + x.size() - 1 applications of comp if (&x != this); otherwise, no
applications of comp are performed. If an exception is thrown other than by a comparison there are no
effects.
void reverse() noexcept;
26
Effects: Reverses the order of the elements in the list. Does not affect the validity of iterators and
references.
27
Complexity: Linear time.
void sort();
template<class Compare> void sort(Compare comp);
28
Effects: Sorts the list according to the operator< or a Compare function object. If an exception is
thrown, the order of the elements in *this is unspecified. Does not affect the validity of iterators and
references.
29
Remarks: Stable (20.5.5.7).
§ 26.3.10.5
802
30
Complexity: Approximately N log N comparisons, where N == size().
26.3.10.6
list specialized algorithms
[list.special]
template<class T, class Allocator>
void swap(list<T, Allocator>& x, list<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.3.11
Class template vector
[vector]
26.3.11.1
Class template vector overview
[vector.overview]
1
A vector is a sequence container that supports (amortized) constant time insert and erase operations at the
end; insert and erase in the middle take linear time. Storage management is handled automatically, though
hints can be given to improve efficiency.
2
A vector satisfies all of the requirements of a container and of a reversible container (given in two tables
in 26.2), of a sequence container, including most of the optional sequence container requirements (26.2.3),
of an allocator-aware container (Table 86), and, for an element type other than bool, of a contiguous
container (26.2.1). The exceptions are the push_front, pop_front, and emplace_front member functions,
which are not provided. Descriptions are provided here only for operations on vector that are not described
in one of these tables or for operations where there is additional semantic information.
namespace std {
template<class T, class Allocator = allocator<T>>
class vector {
public:
// types
using value_type
= T;
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// 26.3.11.2, construct/copy/destroy
vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
explicit vector(const Allocator&) noexcept;
explicit vector(size_type n, const Allocator& = Allocator());
vector(size_type n, const T& value, const Allocator& = Allocator());
template<class InputIterator>
vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
vector(const vector& x);
vector(vector&&) noexcept;
vector(const vector&, const Allocator&);
vector(vector&&, const Allocator&);
vector(initializer_list<T>, const Allocator& = Allocator());
~vector();
vector& operator=(const vector& x);
vector& operator=(vector&& x)
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value
||
allocator_traits<Allocator>::is_always_equal::value);
vector& operator=(initializer_list<T>);
template<class InputIterator>
void assign(InputIterator first, InputIterator last);
void assign(size_type n, const T& u);
void assign(initializer_list<T>);
allocator_type get_allocator() const noexcept;
§
26.3.11.1
803
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// 26.3.11.3, capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
void
resize(size_type sz);
void
resize(size_type sz, const T& c);
void
reserve(size_type n);
void
shrink_to_fit();
// element access
reference
operator[](size_type n);
const_reference operator[](size_type n) const;
const_reference at(size_type n) const;
reference
at(size_type n);
reference
front();
const_reference front() const;
reference
back();
const_reference back() const;
// 26.3.11.4, data access
T*
data() noexcept;
const T* data() const noexcept;
// 26.3.11.5, modifiers
template<class... Args> reference emplace_back(Args&&...
args);
void push_back(const T& x);
void push_back(T&& x);
void pop_back();
template<class... Args> iterator emplace(const_iterator position,
Args&&...
args);
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<T> il);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void
swap(vector&)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
void
clear() noexcept;
};
template<class InputIterator,
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
vector(InputIterator, InputIterator, Allocator = Allocator())
-> vector<typename iterator_traits<InputIterator>::value_type, Allocator>;
§
26.3.11.1
804
// 26.3.11.6, specialized algorithms
template<class T, class Allocator>
void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
}
3
An incomplete type T may be used when instantiating vector if the allocator satisfies the allocator com-
pleteness requirements (20.5.3.5.1). T shall be complete before any member of the resulting specialization of
vector is referenced.
26.3.11.2
vector constructors, copy, and assignment
[vector.cons]
explicit vector(const Allocator&);
1
Effects: Constructs an empty vector, using the specified allocator.
2
Complexity: Constant.
explicit vector(size_type n, const Allocator& = Allocator());
3
Effects: Constructs a vector with n default-inserted elements using the specified allocator.
4
Requires: T shall be DefaultInsertable into *this.
5
Complexity: Linear in n.
vector(size_type n, const T& value,
const Allocator& = Allocator());
6
Effects: Constructs a vector with n copies of value, using the specified allocator.
7
Requires: T shall be CopyInsertable into *this.
8
Complexity: Linear in n.
template<class InputIterator>
vector(InputIterator first, InputIterator last,
const Allocator& = Allocator());
9
Effects: Constructs a vector equal to the range [first, last), using the specified allocator.
10
Complexity: Makes only N calls to the copy constructor of T (where N is the distance between first
and last) and no reallocations if iterators first and last are of forward, bidirectional, or random
access categories. It makes order N calls to the copy constructor of T and order log N reallocations if
they are just input iterators.
26.3.11.3
vector capacity
[vector.capacity]
size_type capacity() const noexcept;
1
Returns: The total number of elements that the vector can hold without requiring reallocation.
void reserve(size_type n);
2
Requires: T shall be MoveInsertable into *this.
3
Effects: A directive that informs a vector of a planned change in size, so that it can manage the storage
allocation accordingly. After reserve(), capacity() is greater or equal to the argument of reserve if
reallocation happens; and equal to the previous value of capacity() otherwise. Reallocation happens
at this point if and only if the current capacity is less than the argument of reserve(). If an exception
is thrown other than by the move constructor of a non-CopyInsertable type, there are no effects.
4
Complexity: It does not change the size of the sequence and takes at most linear time in the size of the
sequence.
5
Throws: length_error if n > max_size().263
6
Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in
the sequence. No reallocation shall take place during insertions that happen after a call to reserve()
until the time when an insertion would make the size of the vector greater than the value of capacity().
263) reserve() uses Allocator::allocate() which may throw an appropriate exception.
§ 26.3.11.3
805
void shrink_to_fit();
7
Requires: T shall be MoveInsertable into *this.
8
Effects: shrink_to_fit is a non-binding request to reduce capacity() to size(). [ Note: The request
is non-binding to allow latitude for implementation-specific optimizations.
— end note ] It does not
increase capacity(), but may reduce capacity() by causing reallocation. If an exception is thrown
other than by the move constructor of a non-CopyInsertable T there are no effects.
9
Complexity: Linear in the size of the sequence.
10
Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in
the sequence as well as the past-the-end iterator. If no reallocation happens, they remain valid.
void swap(vector& x)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
11
Effects: Exchanges the contents and capacity() of *this with that of x.
12
Complexity: Constant time.
void resize(size_type sz);
13
Effects: If sz
< size(), erases the last size() - sz elements from the sequence. Otherwise, appends
sz - size() default-inserted elements to the sequence.
14
Requires: T shall be MoveInsertable and DefaultInsertable into *this.
15
Remarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T
there are no effects.
void resize(size_type sz, const T& c);
16
Effects: If sz
< size(), erases the last size() - sz elements from the sequence. Otherwise, appends
sz - size() copies of c to the sequence.
17
Requires: T shall be CopyInsertable into *this.
18
Remarks: If an exception is thrown there are no effects.
26.3.11.4
vector data
[vector.data]
T*
data() noexcept;
const T*
data() const noexcept;
1
Returns: A pointer such that [data(), data() + size()) is a valid range. For a non-empty vector,
data() == addressof(front()).
2
Complexity: Constant time.
26.3.11.5
vector modifiers
[vector.modifiers]
iterator insert(const_iterator position, const T& x);
iterator insert(const_iterator position, T&& x);
iterator insert(const_iterator position, size_type n, const T& x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<T>);
template<class... Args> reference emplace_back(Args&&... args);
template<class... Args> iterator emplace(const_iterator position, Args&&... args);
void push_back(const T& x);
void push_back(T&& x);
1
Remarks: Causes reallocation if the new size is greater than the old capacity. Reallocation invalidates
all the references, pointers, and iterators referring to the elements in the sequence. If no reallocation
happens, all the iterators and references before the insertion point remain valid. If an exception is
thrown other than by the copy constructor, move constructor, assignment operator, or move assignment
operator of T or by any InputIterator operation there are no effects. If an exception is thrown while
§ 26.3.11.5
806
inserting a single element at the end and T is CopyInsertable or is_nothrow_move_constructible_-
v<T> is true, there are no effects. Otherwise, if an exception is thrown by the move constructor of a
non-CopyInsertable T, the effects are unspecified.
2
Complexity: The complexity is linear in the number of elements inserted plus the distance to the end of
the vector.
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void pop_back();
3
Effects: Invalidates iterators and references at or after the point of the erase.
4
Complexity: The destructor of T is called the number of times equal to the number of the elements
erased, but the assignment operator of T is called the number of times equal to the number of elements
in the vector after the erased elements.
5
Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator
of T.
26.3.11.6
vector specialized algorithms
[vector.special]
template<class T, class Allocator>
void swap(vector<T, Allocator>& x, vector<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.3.12
Class vector<bool>
[vector.bool]
1
To optimize space allocation, a specialization of vector for bool elements is provided:
namespace std {
template<class Allocator>
class vector<bool, Allocator> {
public:
// types
using value_type
= bool;
using allocator_type
= Allocator;
using pointer
= implementation-defined ;
using const_pointer
= implementation-defined ;
using const_reference
= bool;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// bit reference
class reference {
friend class vector;
reference() noexcept;
public:
~reference();
operator bool() const noexcept;
reference& operator=(const bool x) noexcept;
reference& operator=(const reference& x) noexcept;
void flip() noexcept;
// flips the bit
};
// construct/copy/destroy
vector() : vector(Allocator()) { }
explicit vector(const Allocator&);
explicit vector(size_type n, const Allocator& = Allocator());
vector(size_type n, const bool& value, const Allocator& = Allocator());
template<class InputIterator>
vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
§
26.3.12
807
vector(const vector& x);
vector(vector&& x);
vector(const vector&, const Allocator&);
vector(vector&&, const Allocator&);
vector(initializer_list<bool>, const Allocator& = Allocator()));
~vector();
vector& operator=(const vector& x);
vector& operator=(vector&& x);
vector& operator=(initializer_list<bool>);
template<class InputIterator>
void assign(InputIterator first, InputIterator
last);
void assign(size_type n, const bool& t);
void assign(initializer_list<bool>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
void
resize(size_type sz, bool c = false);
void
reserve(size_type n);
void
shrink_to_fit();
// element access
reference
operator[](size_type n);
const_reference operator[](size_type n) const;
const_reference at(size_type n) const;
reference
at(size_type n);
reference
front();
const_reference front() const;
reference
back();
const_reference back() const;
// modifiers
template<class... Args> reference emplace_back(Args&&...
args);
void push_back(const bool& x);
void pop_back();
template<class... Args> iterator emplace(const_iterator position,
Args&&...
args);
iterator insert(const_iterator position, const bool& x);
iterator insert(const_iterator position, size_type n, const bool&
x);
template<class InputIterator>
iterator insert(const_iterator position, InputIterator first, InputIterator last);
iterator insert(const_iterator position, initializer_list<bool> il);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
void swap(vector&);
static void swap(reference x, reference y) noexcept;
§
26.3.12
808
void flip() noexcept;
// flips all bits
void clear() noexcept;
};
}
2
Unless described below, all operations have the same requirements and semantics as the primary vector
template, except that operations dealing with the bool value type map to bit values in the container storage
and allocator_traits::construct (23.10.9.2) is not used to construct these values.
3
There is no requirement that the data be stored as a contiguous allocation of bool values. A space-optimized
representation of bits is recommended instead.
4
reference is a class that simulates the behavior of references of a single bit in vector<bool>. The conversion
function returns true when the bit is set, and false otherwise. The assignment operator sets the bit when
the argument is (convertible to) true and clears it otherwise. flip reverses the state of the bit.
void flip() noexcept;
5
Effects: Replaces each element in the container with its complement.
static void swap(reference x, reference y) noexcept;
6
Effects: Exchanges the contents of x and y as if by:
bool b = x;
x = y;
y = b;
template<class Allocator> struct hash<vector<bool, Allocator>>;
7
The specialization is enabled (23.14.15).
26.4
Associative containers
[associative]
26.4.1
In general
[associative.general]
1
The header <map> defines the class templates map and multimap; the header <set> defines the class templates
set and multiset.
2
The following exposition-only alias templates may appear in deduction guides for associative containers:
template<class InputIterator>
using iter_key_t = remove_const_t<
typename iterator_traits<InputIterator>::value_type::first_type>; // exposition only
template<class InputIterator>
using iter_val_t
= typename iterator_traits<InputIterator>::value_type::second_type; // exposition only
template<class InputIterator>
using iter_to_alloc_t
= pair<add_const_t<typename iterator_traits<InputIterator>::value_type::first_type>,
typename iterator_traits<InputIterator>::value_type::second_type>; // exposition only
26.4.2
Header <map> synopsis
[associative.map.syn]
#include <initializer_list>
namespace std {
// 26.4.4, class template map
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
class map;
template<class Key, class T, class Compare, class Allocator>
bool operator==(const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
bool operator< (const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
bool operator!=(const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
§ 26.4.2
809
template<class Key, class T, class Compare, class Allocator>
bool operator> (const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
bool operator>=(const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
bool operator<=(const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
void swap(map<Key, T, Compare, Allocator>& x,
map<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
// 26.4.5, class template multimap
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
class multimap;
template<class Key, class T, class Compare, class Allocator>
bool operator==(const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
bool operator< (const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
bool operator!=(const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
bool operator> (const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
bool operator>=(const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
bool operator<=(const multimap<Key, T, Compare, Allocator>&
x,
const multimap<Key, T, Compare, Allocator>&
y);
template<class Key, class T, class Compare, class Allocator>
void swap(multimap<Key, T, Compare, Allocator>& x,
multimap<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
namespace pmr {
template<class Key, class T, class Compare = less<Key>>
using map = std::map<Key, T, Compare,
polymorphic_allocator<pair<const Key, T>>>;
template<class Key, class T, class Compare = less<Key>>
using multimap = std::multimap<Key, T, Compare,
polymorphic_allocator<pair<const Key,
T>>>;
}
}
26.4.3
Header <set> synopsis
[associative.set.syn]
#include <initializer_list>
namespace std {
// 26.4.6, class template set
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
class set;
§ 26.4.3
810
template<class Key, class Compare, class Allocator>
bool operator==(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator< (const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator!=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator> (const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator>=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator<=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
void swap(set<Key, Compare, Allocator>& x,
set<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
// 26.4.7, class template multiset
template<class Key, class Compare = less<Key>, class Allocator
=
allocator<Key>>
class multiset;
template<class Key, class Compare, class Allocator>
bool operator==(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator< (const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator!=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator> (const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator>=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
bool operator<=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template<class Key, class Compare, class Allocator>
void swap(multiset<Key, Compare, Allocator>& x,
multiset<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
namespace pmr {
template<class Key, class Compare = less<Key>>
using set = std::set<Key, Compare, polymorphic_allocator<Key>>;
template<class Key, class Compare = less<Key>>
using multiset = std::multiset<Key, Compare, polymorphic_allocator<Key>>;
}
}
§ 26.4.3
811
26.4.4
Class template map
[map]
26.4.4.1
Class template map overview
[map.overview]
1
A map is an associative container that supports unique keys (contains at most one of each key value) and
provides for fast retrieval of values of another type T based on the keys. The map class supports bidirectional
iterators.
2
A map satisfies all of the requirements of a container, of a reversible container (26.2), of an associative
container (26.2.6), and of an allocator-aware container (Table 86). A map also provides most operations
described in 26.2.6 for unique keys. This means that a map supports the a_uniq operations in 26.2.6 but not
the a_eq operations. For a map<Key,T> the key_type is Key and the value_type is pair<const Key,T>.
Descriptions are provided here only for operations on map that are not described in one of those tables or for
operations where there is additional semantic information.
namespace std {
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
class map {
public:
// types
using key_type
= Key;
using mapped_type
= T;
using value_type
= pair<const Key, T>;
using key_compare
= Compare;
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using node_type
= unspecified ;
using insert_return_type
= INSERT_RETURN_TYPE<iterator, node_type>;
class value_compare {
friend class map;
protected:
Compare comp;
value_compare(Compare c) : comp(c) {}
public:
bool operator()(const value_type& x, const value_type& y) const {
return comp(x.first, y.first);
}
};
// 26.4.4.2, construct/copy/destroy
map() : map(Compare()) { }
explicit map(const Compare& comp, const Allocator& = Allocator());
template<class InputIterator>
map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
map(const map& x);
map(map&& x);
explicit map(const Allocator&);
map(const map&, const Allocator&);
map(map&&, const Allocator&);
map(initializer_list<value_type>,
const Compare& = Compare(),
const Allocator& = Allocator());
§ 26.4.4.1
812
template<class InputIterator>
map(InputIterator first, InputIterator last, const Allocator& a)
: map(first, last, Compare(), a) { }
map(initializer_list<value_type> il, const Allocator& a)
: map(il, Compare(), a) { }
~map();
map& operator=(const map& x);
map& operator=(map&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_move_assignable_v<Compare>);
map& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
// 26.4.4.3, element access
T& operator[](const key_type& x);
T& operator[](key_type&& x);
T&
at(const key_type& x);
const T& at(const key_type& x) const;
// 26.4.4.4, modifiers
template<class... Args> pair<iterator, bool> emplace(Args&&...
args);
template<class... Args> iterator emplace_hint(const_iterator position,
Args&&...
args);
pair<iterator, bool> insert(const value_type& x);
pair<iterator, bool> insert(value_type&& x);
template<class P> pair<iterator, bool> insert(P&& x);
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, value_type&& x);
template<class P>
iterator insert(const_iterator position, P&&);
template<class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
node_type extract(const_iterator position);
node_type extract(const key_type& x);
insert_return_type insert(node_type&& nh);
iterator
insert(const_iterator hint, node_type&& nh);
template<class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template<class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
§
26.4.4.1
813
template<class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
template<class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
template<class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template<class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, key_type&& k,
M&&
obj);
iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);
void
swap(map&)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_swappable_v<Compare>);
void
clear() noexcept;
template<class C2>
void merge(map<Key, T, C2, Allocator>& source);
template<class C2>
void merge(map<Key, T, C2, Allocator>&& source);
template<class C2>
void merge(multimap<Key, T, C2, Allocator>& source);
template<class C2>
void merge(multimap<Key, T, C2, Allocator>&& source);
// observers
key_compare key_comp() const;
value_compare value_comp() const;
// map operations
iterator
find(const key_type& x);
const_iterator find(const key_type& x) const;
template<class K> iterator
find(const K& x);
template<class K> const_iterator find(const K& x) const;
size_type
count(const key_type& x) const;
template<class K> size_type count(const K& x) const;
iterator
lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
template<class K> iterator
lower_bound(const K& x);
template<class K> const_iterator lower_bound(const K& x) const;
iterator
upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
template<class K> iterator
upper_bound(const K& x);
template<class K> const_iterator upper_bound(const K& x) const;
pair<iterator, iterator>
equal_range(const key_type&
x);
pair<const_iterator, const_iterator>
equal_range(const key_type&
x) const;
template<class K>
pair<iterator, iterator>
equal_range(const K& x);
template<class K>
pair<const_iterator, const_iterator> equal_range(const K& x) const;
};
§ 26.4.4.1
814
template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
-> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
-> map<Key, T, Compare, Allocator>;
template<class InputIterator, class Allocator>
map(InputIterator, InputIterator, Allocator)
-> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
less<iter_key_t<InputIterator>>, Allocator>;
template<class Key, class T, class Allocator>
map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
// 26.4.4.5, specialized algorithms
template<class Key, class T, class Compare, class Allocator>
void swap(map<Key, T, Compare, Allocator>& x,
map<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
}
26.4.4.2
map constructors, copy, and assignment
[map.cons]
explicit map(const Compare& comp, const Allocator& = Allocator());
1
Effects: Constructs an empty map using the specified comparison object and allocator.
2
Complexity: Constant.
template<class InputIterator>
map(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
3
Effects: Constructs an empty map using the specified comparison object and allocator, and inserts
elements from the range [first, last).
4
Complexity: Linear in N if the range [first, last) is already sorted using comp and otherwise
N log N , where N is last - first.
26.4.4.3
map element access
[map.access]
T& operator[](const key_type& x);
1
Effects: Equivalent to: return try_emplace(x).first->second;
T& operator[](key_type&& x);
2
Effects: Equivalent to: return try_emplace(move(x)).first->second;
T&
at(const key_type& x);
const T& at(const key_type& x) const;
3
Returns: A reference to the mapped_type corresponding to x in *this.
4
Throws: An exception object of type out_of_range if no such element is present.
5
Complexity: Logarithmic.
26.4.4.4
map modifiers
[map.modifiers]
template<class P>
pair<iterator, bool> insert(P&& x);
template<class P>
iterator insert(const_iterator position, P&& x);
1
Effects: The first form is equivalent to return emplace(std::forward<P>(x)). The second form is
equivalent to return emplace_hint(position, std::forward<P>(x)).
§ 26.4.4.4
815
2
Remarks: These signatures shall not participate in overload resolution unless is_constructible_-
v<value_type, P&&> is true.
template<class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template<class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
3
Requires: value_type shall be EmplaceConstructible into map from piecewise_construct, for-
ward_as_tuple(k), forward_as_tuple(std::forward<Args>(args)...).
4
Effects: If the map already contains an element whose key is equivalent to k, there is no effect. Otherwise
inserts an object of type value_type constructed with piecewise_construct, forward_as_tuple(k),
forward_as_tuple(std::forward<Args>(args)...).
5
Returns: In the first overload, the bool component of the returned pair is true if and only if the
insertion took place. The returned iterator points to the map element whose key is equivalent to k.
6
Complexity: The same as emplace and emplace_hint, respectively.
template<class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
template<class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
7
Requires: value_type shall be EmplaceConstructible into map from piecewise_construct, for-
ward_as_tuple(std::move(k)), forward_as_tuple(std::forward<Args>(args)...).
8
Effects: If the map already contains an element whose key is equivalent to k, there is no effect.
Otherwise inserts an object of type value_type constructed with piecewise_construct, forward_-
as_tuple(std::move(k)), forward_as_tuple(std::forward<Args>(args)...).
9
Returns: In the first overload, the bool component of the returned pair is true if and only if the
insertion took place. The returned iterator points to the map element whose key is equivalent to k.
10
Complexity: The same as emplace and emplace_hint, respectively.
template<class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
11
Requires: is_assignable_v<mapped_type&, M&&> shall be true. value_type shall be Emplace-
Constructible into map from k, forward<M>(obj).
12
Effects: If the map already contains an element e whose key is equivalent to k, assigns std::for-
ward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with k,
std::forward<M>(obj).
13
Returns: In the first overload, the bool component of the returned pair is true if and only if the
insertion took place. The returned iterator points to the map element whose key is equivalent to k.
14
Complexity: The same as emplace and emplace_hint, respectively.
template<class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
15
Requires: is_assignable_v<mapped_type&, M&&> shall be true. value_type shall be Emplace-
Constructible into map from move(k), forward<M>(obj).
16
Effects: If the map already contains an element e whose key is equivalent to k, assigns std::for-
ward<M>(obj) to e.second. Otherwise inserts an object of type value_type constructed with std::
move(k), std::forward<M>(obj).
17
Returns: In the first overload, the bool component of the returned pair is true if and only if the
insertion took place. The returned iterator points to the map element whose key is equivalent to k.
18
Complexity: The same as emplace and emplace_hint, respectively.
§ 26.4.4.4
816
26.4.4.5
map specialized algorithms
[map.special]
template<class Key, class T, class Compare, class Allocator>
void swap(map<Key, T, Compare, Allocator>& x,
map<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.4.5
Class template multimap
[multimap]
26.4.5.1
Class template multimap overview
[multimap.overview]
1
A multimap is an associative container that supports equivalent keys (possibly containing multiple copies
of the same key value) and provides for fast retrieval of values of another type T based on the keys. The
multimap class supports bidirectional iterators.
2
A multimap satisfies all of the requirements of a container and of a reversible container (26.2), of an associative
container (26.2.6), and of an allocator-aware container (Table 86). A multimap also provides most operations
described in 26.2.6 for equal keys. This means that a multimap supports the a_eq operations in 26.2.6 but
not the a_uniq operations. For a multimap<Key,T> the key_type is Key and the value_type is pair<const
Key,T>. Descriptions are provided here only for operations on multimap that are not described in one of
those tables or for operations where there is additional semantic information.
namespace std {
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
class multimap {
public:
// types
using key_type
= Key;
using mapped_type
= T;
using value_type
= pair<const Key, T>;
using key_compare
= Compare;
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using node_type
= unspecified ;
class value_compare {
friend class multimap;
protected:
Compare comp;
value_compare(Compare c) : comp(c) { }
public:
bool operator()(const value_type& x, const value_type& y) const {
return comp(x.first, y.first);
}
};
// 26.4.5.2, construct/copy/destroy
multimap() : multimap(Compare()) { }
explicit multimap(const Compare& comp, const Allocator& = Allocator());
template<class InputIterator>
multimap(InputIterator first, InputIterator last,
const Compare& comp = Compare(),
const Allocator& = Allocator());
multimap(const multimap& x);
§
26.4.5.1
817
multimap(multimap&& x);
explicit multimap(const Allocator&);
multimap(const multimap&, const Allocator&);
multimap(multimap&&, const Allocator&);
multimap(initializer_list<value_type>,
const Compare& = Compare(),
const Allocator& = Allocator());
template<class InputIterator>
multimap(InputIterator first, InputIterator last, const Allocator&
a)
: multimap(first, last, Compare(), a) { }
multimap(initializer_list<value_type> il, const Allocator& a)
: multimap(il, Compare(), a) { }
~multimap();
multimap& operator=(const multimap& x);
multimap& operator=(multimap&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_move_assignable_v<Compare>);
multimap& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
// 26.4.5.3, modifiers
template<class... Args> iterator emplace(Args&&... args);
template<class... Args> iterator emplace_hint(const_iterator
position,
Args&&...
args);
iterator insert(const value_type& x);
iterator insert(value_type&& x);
template<class P> iterator insert(P&& x);
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, value_type&& x);
template<class P> iterator insert(const_iterator position, P&& x);
template<class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
node_type extract(const_iterator position);
node_type extract(const key_type& x);
iterator insert(node_type&& nh);
iterator insert(const_iterator hint, node_type&& nh);
iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);
§
26.4.5.1
818
void
swap(multimap&)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_swappable_v<Compare>);
void
clear() noexcept;
template<class C2>
void merge(multimap<Key, T, C2, Allocator>& source);
template<class C2>
void merge(multimap<Key, T, C2, Allocator>&& source);
template<class C2>
void merge(map<Key, T, C2, Allocator>& source);
template<class C2>
void merge(map<Key, T, C2, Allocator>&& source);
// observers
key_compare key_comp() const;
value_compare value_comp() const;
// map operations
iterator
find(const key_type& x);
const_iterator find(const key_type& x) const;
template<class K> iterator
find(const K& x);
template<class K> const_iterator find(const K& x) const;
size_type
count(const key_type& x) const;
template<class K> size_type count(const K& x) const;
iterator
lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
template<class K> iterator
lower_bound(const K& x);
template<class K> const_iterator lower_bound(const K& x) const;
iterator
upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
template<class K> iterator
upper_bound(const K& x);
template<class K> const_iterator upper_bound(const K& x) const;
pair<iterator, iterator>
equal_range(const key_type&
x);
pair<const_iterator, const_iterator>
equal_range(const key_type&
x) const;
template<class K>
pair<iterator, iterator>
equal_range(const K& x);
template<class K>
pair<const_iterator, const_iterator> equal_range(const K& x) const;
};
template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
-> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
-> multimap<Key, T, Compare, Allocator>;
template<class InputIterator, class Allocator>
multimap(InputIterator, InputIterator, Allocator)
-> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
less<iter_key_t<InputIterator>>, Allocator>;
template<class Key, class T, class Allocator>
multimap(initializer_list<pair<const Key, T>>, Allocator)
-> multimap<Key, T, less<Key>, Allocator>;
§
26.4.5.1
819
// 26.4.5.4, specialized algorithms
template<class Key, class T, class Compare, class Allocator>
void swap(multimap<Key, T, Compare, Allocator>& x,
multimap<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
}
26.4.5.2
multimap constructors
[multimap.cons]
explicit multimap(const Compare& comp, const Allocator& = Allocator());
1
Effects: Constructs an empty multimap using the specified comparison object and allocator.
2
Complexity: Constant.
template<class InputIterator>
multimap(InputIterator first, InputIterator last,
const Compare& comp = Compare(),
const Allocator& = Allocator());
3
Effects: Constructs an empty multimap using the specified comparison object and allocator, and inserts
elements from the range [first, last).
4
Complexity: Linear in N if the range [first, last) is already sorted using comp and otherwise
N log N , where N is last - first.
26.4.5.3
multimap modifiers
[multimap.modifiers]
template<class P> iterator insert(P&& x);
template<class P> iterator insert(const_iterator position, P&& x);
1
Effects: The first form is equivalent to return emplace(std::forward<P>(x)). The second form is
equivalent to return emplace_hint(position, std::forward<P>(x)).
2
Remarks: These signatures shall not participate in overload resolution unless is_constructible_-
v<value_type, P&&> is true.
26.4.5.4
multimap specialized algorithms
[multimap.special]
template<class Key, class T, class Compare, class Allocator>
void swap(multimap<Key, T, Compare, Allocator>& x,
multimap<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.4.6
Class template set
[set]
26.4.6.1
Class template set overview
[set.overview]
1
A set is an associative container that supports unique keys (contains at most one of each key value) and
provides for fast retrieval of the keys themselves. The set class supports bidirectional iterators.
2
A set satisfies all of the requirements of a container, of a reversible container (26.2), of an associative
container (26.2.6), and of an allocator-aware container (Table 86). A set also provides most operations
described in 26.2.6 for unique keys. This means that a set supports the a_uniq operations in 26.2.6 but
not the a_eq operations. For a set<Key> both the key_type and value_type are Key. Descriptions are
provided here only for operations on set that are not described in one of these tables and for operations
where there is additional semantic information.
namespace std {
template<class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
class set {
public:
// types
using key_type
= Key;
using key_compare
= Compare;
using value_type
= Key;
using value_compare
= Compare;
§ 26.4.6.1
820
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using node_type
= unspecified ;
using insert_return_type
= INSERT_RETURN_TYPE<iterator, node_type>;
// 26.4.6.2, construct/copy/destroy
set() : set(Compare()) { }
explicit set(const Compare& comp, const Allocator& = Allocator());
template<class InputIterator>
set(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
set(const set& x);
set(set&& x);
explicit set(const Allocator&);
set(const set&, const Allocator&);
set(set&&, const Allocator&);
set(initializer_list<value_type>, const Compare& = Compare(),
const Allocator& = Allocator());
template<class InputIterator>
set(InputIterator first, InputIterator last, const Allocator& a)
: set(first, last, Compare(), a) { }
set(initializer_list<value_type> il, const Allocator& a)
: set(il, Compare(), a) { }
~set();
set& operator=(const set& x);
set& operator=(set&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_move_assignable_v<Compare>);
set& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
// modifiers
template<class... Args> pair<iterator, bool> emplace(Args&&...
args);
template<class... Args> iterator emplace_hint(const_iterator position,
Args&&...
args);
§
26.4.6.1
821
pair<iterator,bool> insert(const value_type& x);
pair<iterator,bool> insert(value_type&& x);
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, value_type&& x);
template<class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
node_type extract(const_iterator position);
node_type extract(const key_type& x);
insert_return_type insert(node_type&& nh);
iterator
insert(const_iterator hint, node_type&& nh);
iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);
void
swap(set&)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_swappable_v<Compare>);
void
clear() noexcept;
template<class C2>
void merge(set<Key, C2, Allocator>& source);
template<class C2>
void merge(set<Key, C2, Allocator>&& source);
template<class C2>
void merge(multiset<Key, C2, Allocator>& source);
template<class C2>
void merge(multiset<Key, C2, Allocator>&& source);
// observers
key_compare key_comp() const;
value_compare value_comp() const;
// set operations
iterator
find(const key_type& x);
const_iterator find(const key_type& x) const;
template<class K> iterator
find(const K& x);
template<class K> const_iterator find(const K& x) const;
size_type
count(const key_type& x) const;
template<class K> size_type count(const K& x) const;
iterator
lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
template<class K> iterator
lower_bound(const K& x);
template<class K> const_iterator lower_bound(const K& x) const;
iterator
upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
template<class K> iterator
upper_bound(const K& x);
template<class K> const_iterator upper_bound(const K& x) const;
pair<iterator, iterator>
equal_range(const key_type&
x);
pair<const_iterator, const_iterator>
equal_range(const key_type&
x) const;
template<class K>
pair<iterator, iterator>
equal_range(const K& x);
template<class K>
pair<const_iterator, const_iterator> equal_range(const K& x) const;
};
§ 26.4.6.1
822
template<class InputIterator,
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
set(InputIterator, InputIterator,
Compare = Compare(), Allocator = Allocator())
-> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>;
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
-> set<Key, Compare, Allocator>;
template<class InputIterator, class Allocator>
set(InputIterator, InputIterator, Allocator)
-> set<typename iterator_traits<InputIterator>::value_type,
less<typename iterator_traits<InputIterator>::value_type>, Allocator>;
template<class Key, class Allocator>
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
// 26.4.6.3, specialized algorithms
template<class Key, class Compare, class Allocator>
void swap(set<Key, Compare, Allocator>& x,
set<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
}
26.4.6.2
set constructors, copy, and assignment
[set.cons]
explicit set(const Compare& comp, const Allocator& = Allocator());
1
Effects: Constructs an empty set using the specified comparison objects and allocator.
2
Complexity: Constant.
template<class InputIterator>
set(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
3
Effects: Constructs an empty set using the specified comparison object and allocator, and inserts
elements from the range [first, last).
4
Complexity: Linear in N if the range [first, last) is already sorted using comp and otherwise
N log N , where N is last - first.
26.4.6.3
set specialized algorithms
[set.special]
template<class Key, class Compare, class Allocator>
void swap(set<Key, Compare, Allocator>& x,
set<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.4.7
Class template multiset
[multiset]
26.4.7.1
Class template multiset overview
[multiset.overview]
1
A multiset is an associative container that supports equivalent keys (possibly contains multiple copies of
the same key value) and provides for fast retrieval of the keys themselves. The multiset class supports
bidirectional iterators.
2
A multiset satisfies all of the requirements of a container, of a reversible container (26.2), of an associative
container (26.2.6), and of an allocator-aware container (Table 86). multiset also provides most operations
described in 26.2.6 for duplicate keys. This means that a multiset supports the a_eq operations in 26.2.6 but
not the a_uniq operations. For a multiset<Key> both the key_type and value_type are Key. Descriptions
are provided here only for operations on multiset that are not described in one of these tables and for
operations where there is additional semantic information.
§ 26.4.7.1
823
namespace std {
template<class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
class multiset {
public:
// types
using key_type
= Key;
using key_compare
= Compare;
using value_type
= Key;
using value_compare
= Compare;
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using reverse_iterator
= std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using node_type
= unspecified ;
// 26.4.7.2, construct/copy/destroy
multiset() : multiset(Compare()) { }
explicit multiset(const Compare& comp, const Allocator& = Allocator());
template<class InputIterator>
multiset(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
multiset(const multiset& x);
multiset(multiset&& x);
explicit multiset(const Allocator&);
multiset(const multiset&, const Allocator&);
multiset(multiset&&, const Allocator&);
multiset(initializer_list<value_type>, const Compare& = Compare(),
const Allocator& = Allocator());
template<class InputIterator>
multiset(InputIterator first, InputIterator last, const Allocator&
a)
: multiset(first, last, Compare(), a) { }
multiset(initializer_list<value_type> il, const Allocator& a)
: multiset(il, Compare(), a) { }
~multiset();
multiset& operator=(const multiset& x);
multiset& operator=(multiset&& x)
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
is_nothrow_move_assignable_v<Compare>);
multiset& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator
begin() const noexcept;
iterator
end() noexcept;
const_iterator
end() const noexcept;
reverse_iterator
rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator
rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator
cbegin() const noexcept;
const_iterator
cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
§
26.4.7.1
824
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
// modifiers
template<class... Args> iterator emplace(Args&&... args);
template<class... Args> iterator emplace_hint(const_iterator position,
Args&&...
args);
iterator insert(const value_type& x);
iterator insert(value_type&& x);
iterator insert(const_iterator position, const value_type& x);
iterator insert(const_iterator position, value_type&& x);
template<class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
node_type extract(const_iterator position);
node_type extract(const key_type& x);
iterator insert(node_type&& nh);
iterator insert(const_iterator hint, node_type&& nh);
iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);
void
swap(multiset&)
noexcept(allocator_traits<Allocator>::is_always_equal::value
&&
is_nothrow_swappable_v<Compare>);
void
clear() noexcept;
template<class C2>
void merge(multiset<Key, C2, Allocator>& source);
template<class C2>
void merge(multiset<Key, C2, Allocator>&& source);
template<class C2>
void merge(set<Key, C2, Allocator>& source);
template<class C2>
void merge(set<Key, C2, Allocator>&& source);
// observers
key_compare key_comp() const;
value_compare value_comp() const;
// set operations
iterator
find(const key_type& x);
const_iterator find(const key_type& x) const;
template<class K> iterator
find(const K& x);
template<class K> const_iterator find(const K& x) const;
size_type
count(const key_type& x) const;
template<class K> size_type count(const K& x) const;
iterator
lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x) const;
template<class K> iterator
lower_bound(const K& x);
template<class K> const_iterator lower_bound(const K& x) const;
iterator
upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
template<class K> iterator
upper_bound(const K& x);
template<class K> const_iterator upper_bound(const K& x) const;
pair<iterator, iterator>
equal_range(const key_type&
x);
pair<const_iterator, const_iterator>
equal_range(const key_type&
x) const;
§
26.4.7.1
825
template<class K>
pair<iterator, iterator>
equal_range(const K& x);
template<class K>
pair<const_iterator, const_iterator> equal_range(const K& x) const;
};
template<class InputIterator,
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
multiset(InputIterator, InputIterator,
Compare = Compare(), Allocator = Allocator())
-> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>;
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
-> multiset<Key, Compare, Allocator>;
template<class InputIterator, class Allocator>
multiset(InputIterator, InputIterator, Allocator)
-> multiset<typename iterator_traits<InputIterator>::value_type,
less<typename iterator_traits<InputIterator>::value_type>, Allocator>;
template<class Key, class Allocator>
multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>;
// 26.4.7.3, specialized algorithms
template<class Key, class Compare, class Allocator>
void swap(multiset<Key, Compare, Allocator>& x,
multiset<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
}
26.4.7.2
multiset constructors
[multiset.cons]
explicit multiset(const Compare& comp, const Allocator& = Allocator());
1
Effects: Constructs an empty multiset using the specified comparison object and allocator.
2
Complexity: Constant.
template<class InputIterator>
multiset(InputIterator first, InputIterator last,
const Compare& comp = Compare(), const Allocator& = Allocator());
3
Effects: Constructs an empty multiset using the specified comparison object and allocator, and inserts
elements from the range [first, last).
4
Complexity: Linear in N if the range [first, last) is already sorted using comp and otherwise
N log N , where N is last - first.
26.4.7.3
multiset specialized algorithms
[multiset.special]
template<class Key, class Compare, class Allocator>
void swap(multiset<Key, Compare, Allocator>& x,
multiset<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
1
Effects: As if by x.swap(y).
26.5
Unordered associative containers
[unord]
26.5.1
In general
[unord.general]
1
The header <unordered_map> defines the class templates unordered_map and unordered_multimap; the
header <unordered_set> defines the class templates unordered_set and unordered_multiset.
2
The exposition-only alias templates iter_key_t, iter_val_t, and iter_to_alloc_t defined in 26.4.1 may
appear in deduction guides for unordered containers.
§ 26.5.1
826
26.5.2
Header <unordered_map> synopsis
[unord.map.syn]
#include <initializer_list>
namespace std {
// 26.5.4, class template unordered_map
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Alloc = allocator<pair<const Key, T>>>
class unordered_map;
// 26.5.5, class template unordered_multimap
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Alloc = allocator<pair<const Key, T>>>
class unordered_multimap;
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator==(const unordered_map<Key, T, Hash, Pred, Alloc>&
a,
const unordered_map<Key, T, Hash, Pred, Alloc>&
b);
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>&
a,
const unordered_map<Key, T, Hash, Pred, Alloc>&
b);
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>&
a,
const unordered_multimap<Key, T, Hash, Pred, Alloc>&
b);
template<class Key, class T, class Hash, class Pred, class Alloc>
bool operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>&
a,
const unordered_multimap<Key, T, Hash, Pred, Alloc>&
b);
template<class Key, class T, class Hash, class Pred, class Alloc>
void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
unordered_map<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template<class Key, class T, class Hash, class Pred, class Alloc>
void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
namespace pmr {
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = equal_to<Key>>
using unordered_map =
std::unordered_map<Key, T, Hash, Pred,
polymorphic_allocator<pair<const Key, T>>>;
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = equal_to<Key>>
using unordered_multimap =
std::unordered_multimap<Key, T, Hash, Pred,
polymorphic_allocator<pair<const Key, T>>>;
}
}
§ 26.5.2
827
26.5.3
Header <unordered_set> synopsis
[unord.set.syn]
#include <initializer_list>
namespace std {
// 26.5.6, class template unordered_set
template<class Key,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Alloc = allocator<Key>>
class unordered_set;
// 26.5.7, class template unordered_multiset
template<class Key,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Alloc = allocator<Key>>
class unordered_multiset;
template<class Key, class Hash, class Pred, class Alloc>
bool operator==(const unordered_set<Key, Hash, Pred, Alloc>& a,
const unordered_set<Key, Hash, Pred, Alloc>& b);
template<class Key, class Hash, class Pred, class Alloc>
bool operator!=(const unordered_set<Key, Hash, Pred, Alloc>& a,
const unordered_set<Key, Hash, Pred, Alloc>& b);
template<class Key, class Hash, class Pred, class Alloc>
bool operator==(const unordered_multiset<Key, Hash, Pred, Alloc>&
a,
const unordered_multiset<Key, Hash, Pred, Alloc>&
b);
template<class Key, class Hash, class Pred, class Alloc>
bool operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>&
a,
const unordered_multiset<Key, Hash, Pred, Alloc>&
b);
template<class Key, class Hash, class Pred, class Alloc>
void swap(unordered_set<Key, Hash, Pred, Alloc>& x,
unordered_set<Key, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template<class Key, class Hash, class Pred, class Alloc>
void swap(unordered_multiset<Key, Hash, Pred, Alloc>& x,
unordered_multiset<Key, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
namespace pmr {
template<class Key,
class Hash = hash<Key>,
class Pred = equal_to<Key>>
using unordered_set = std::unordered_set<Key, Hash, Pred,
polymorphic_allocator<Key>>;
template<class Key,
class Hash = hash<Key>,
class Pred = equal_to<Key>>
using unordered_multiset = std::unordered_multiset<Key, Hash, Pred,
polymorphic_allocator<Key>>;
}
}
26.5.4
Class template unordered_map
[unord.map]
26.5.4.1
Class template unordered_map overview
[unord.map.overview]
1
An unordered_map is an unordered associative container that supports unique keys (an unordered_map
contains at most one of each key value) and that associates values of another type mapped_type with the
keys. The unordered_map class supports forward iterators.
§ 26.5.4.1
828
2
An unordered_map satisfies all of the requirements of a container, of an unordered associative container, and
of an allocator-aware container (Table 86). It provides the operations described in the preceding requirements
table for unique keys; that is, an unordered_map supports the a_uniq operations in that table, not the a_eq
operations. For an unordered_map<Key, T> the key type is Key, the mapped type is T, and the value type
is pair<const Key, T>.
3
This subclause only describes operations on unordered_map that are not described in one of the requirement
tables, or for which there is additional semantic information.
namespace std {
template<class Key,
class T,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Allocator = allocator<pair<const Key, T>>>
class unordered_map {
public:
// types
using key_type
= Key;
using mapped_type
= T;
using value_type
= pair<const Key, T>;
using hasher
= Hash;
using key_equal
= Pred;
using allocator_type
= Allocator;
using pointer
= typename allocator_traits<Allocator>::pointer;
using const_pointer
= typename allocator_traits<Allocator>::const_pointer;
using reference
= value_type&;
using const_reference
= const value_type&;
using size_type
= implementation-defined ; // see 26.2
using difference_type
= implementation-defined ; // see 26.2
using iterator
= implementation-defined ; // see 26.2
using const_iterator
= implementation-defined ; // see 26.2
using local_iterator
= implementation-defined ; // see 26.2
using const_local_iterator = implementation-defined ; // see 26.2
using node_type
= unspecified ;
using insert_return_type
= INSERT_RETURN_TYPE<iterator, node_type>;
// 26.5.4.2, construct/copy/destroy
unordered_map();
explicit unordered_map(size_type n,
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l,
size_type n = see below ,
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_map(const unordered_map&);
unordered_map(unordered_map&&);
explicit unordered_map(const Allocator&);
unordered_map(const unordered_map&, const Allocator&);
unordered_map(unordered_map&&, const Allocator&);
unordered_map(initializer_list<value_type> il,
size_type n = see below ,
const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
unordered_map(size_type n, const allocator_type& a)
: unordered_map(n, hasher(), key_equal(), a) { }
unordered_map(size_type n, const hasher& hf, const allocator_type& a)
: unordered_map(n, hf, key_equal(), a) { }
§
26.5.4.1
829
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type&
a)
: unordered_map(f, l, n, hasher(), key_equal(), a) { }
template<class InputIterator>
unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(f, l, n, hf, key_equal(), a) { }
unordered_map(initializer_list<value_type> il, size_type n, const allocator_type&
a)
: unordered_map(il, n, hasher(), key_equal(), a) { }
unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
const allocator_type& a)
: unordered_map(il, n, hf, key_equal(), a) { }
~unordered_map();
unordered_map& operator=(const unordered_map&);
unordered_map& operator=(unordered_map&&)
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
is_nothrow_move_assignable_v<Hash> &&
is_nothrow_move_assignable_v<Pred>);
unordered_map& operator=(initializer_list<value_type>);
allocator_type get_allocator() const noexcept;
// iterators
iterator
begin() noexcept;
const_iterator begin() const noexcept;
iterator
end() noexcept;
const_iterator end() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
// capacity
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
size_type max_size() const noexcept;
// 26.5.4.4, modifiers
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
template<class... Args> iterator emplace_hint(const_iterator position,
Args&&...
args);
pair<iterator, bool> insert(const value_type& obj);
pair<iterator, bool> insert(value_type&& obj);
template<class P> pair<iterator, bool> insert(P&& obj);
iterator
insert(const_iterator hint, const value_type& obj);
iterator
insert(const_iterator hint, value_type&& obj);
template<class P> iterator insert(const_iterator hint, P&& obj);
template<class InputIterator> void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
node_type extract(const_iterator position);
node_type extract(const key_type& x);
insert_return_type insert(node_type&& nh);
iterator
insert(const_iterator hint, node_type&& nh);
template<class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
template<class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
template<class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
template<class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
template<class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
template<class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
§
26.5.4.1
830
template<class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
template<class M>
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void
swap(unordered_map&)
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
is_nothrow_swappable_v<Hash> &&
is_nothrow_swappable_v<Pred>);
void
clear() noexcept;
template<class H2, class P2>
void merge(unordered_map<Key, T, H2, P2, Allocator>& source);
template<class H2, class P2>
void merge(unordered_map<Key, T, H2, P2, Allocator>&& source);
template<class H2, class P2>
void merge(unordered_multimap<Key, T, H2, P2, Allocator>& source);
template<class H2, class P2>
void merge(unordered_multimap<Key, T, H2, P2, Allocator>&& source);
// observers
hasher hash_function() const;
key_equal key_eq() const;
// map operations
iterator
find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type
count(const key_type& k) const;
pair<iterator, iterator>
equal_range(const
key_type&
k);
pair<const_iterator, const_iterator> equal_range(const
key_type&
k) const;
// 26.5.4.3, element access
mapped_type& operator[](const key_type& k);
mapped_type& operator[](key_type&& k);
mapped_type& at(const key_type& k);
const mapped_type& at(const key_type& k) const;
// bucket interface
size_type bucket_count() const noexcept;
size_type max_bucket_count() const noexcept;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
const_local_iterator begin(size_type n) const;
local_iterator end(size_type n);
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
// hash policy
float load_factor() const noexcept;
float max_load_factor() const noexcept;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};
§ 26.5.4.1
831
|
|