tmp/tmps2zd9cl1/{from.md → to.md}
RENAMED
|
@@ -6,19 +6,22 @@ of the keys themselves. The `set` class supports bidirectional
|
|
| 6 |
iterators.
|
| 7 |
|
| 8 |
A `set` meets all of the requirements of a container
|
| 9 |
[[container.reqmts]], of a reversible container
|
| 10 |
[[container.rev.reqmts]], of an allocator-aware container
|
| 11 |
-
[[container.alloc.reqmts]]
|
| 12 |
[[associative.reqmts]]. A `set` also provides most operations described
|
| 13 |
in [[associative.reqmts]] for unique keys. This means that a `set`
|
| 14 |
supports the `a_uniq` operations in [[associative.reqmts]] but not the
|
| 15 |
`a_eq` operations. For a `set<Key>` both the `key_type` and `value_type`
|
| 16 |
are `Key`. Descriptions are provided here only for operations on `set`
|
| 17 |
that are not described in one of these tables and for operations where
|
| 18 |
there is additional semantic information.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
``` cpp
|
| 21 |
namespace std {
|
| 22 |
template<class Key, class Compare = less<Key>,
|
| 23 |
class Allocator = allocator<Key>>
|
| 24 |
class set {
|
|
@@ -27,12 +30,12 @@ namespace std {
|
|
| 27 |
using key_type = Key;
|
| 28 |
using key_compare = Compare;
|
| 29 |
using value_type = Key;
|
| 30 |
using value_compare = Compare;
|
| 31 |
using allocator_type = Allocator;
|
| 32 |
-
using pointer =
|
| 33 |
-
using const_pointer =
|
| 34 |
using reference = value_type&;
|
| 35 |
using const_reference = const value_type&;
|
| 36 |
using size_type = implementation-defined // type of set::size_type; // see [container.requirements]
|
| 37 |
using difference_type = implementation-defined // type of set::difference_type; // see [container.requirements]
|
| 38 |
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
|
@@ -41,132 +44,136 @@ namespace std {
|
|
| 41 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 42 |
using node_type = unspecified;
|
| 43 |
using insert_return_type = insert-return-type<iterator, node_type>;
|
| 44 |
|
| 45 |
// [set.cons], construct/copy/destroy
|
| 46 |
-
set() : set(Compare()) { }
|
| 47 |
-
explicit set(const Compare& comp, const Allocator& = Allocator());
|
| 48 |
template<class InputIterator>
|
| 49 |
-
set(InputIterator first, InputIterator last,
|
| 50 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 51 |
template<container-compatible-range<value_type> R>
|
| 52 |
-
set(from_range_t, R&& rg,
|
| 53 |
-
|
| 54 |
-
set(set&
|
| 55 |
-
|
| 56 |
-
set(const
|
| 57 |
-
set(set&
|
| 58 |
-
set(
|
| 59 |
-
|
|
|
|
| 60 |
template<class InputIterator>
|
| 61 |
-
set(InputIterator first, InputIterator last, const Allocator& a)
|
| 62 |
: set(first, last, Compare(), a) { }
|
| 63 |
template<container-compatible-range<value_type> R>
|
| 64 |
-
set(from_range_t, R&& rg, const Allocator& a)
|
| 65 |
: set(from_range, std::forward<R>(rg), Compare(), a) { }
|
| 66 |
-
set(initializer_list<value_type> il, const Allocator& a)
|
| 67 |
: set(il, Compare(), a) { }
|
| 68 |
-
~set();
|
| 69 |
-
set& operator=(const set& x);
|
| 70 |
-
set& operator=(set&& x)
|
| 71 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 72 |
is_nothrow_move_assignable_v<Compare>);
|
| 73 |
-
set& operator=(initializer_list<value_type>);
|
| 74 |
-
allocator_type get_allocator() const noexcept;
|
| 75 |
|
| 76 |
// iterators
|
| 77 |
-
iterator begin() noexcept;
|
| 78 |
-
const_iterator begin() const noexcept;
|
| 79 |
-
iterator end() noexcept;
|
| 80 |
-
const_iterator end() const noexcept;
|
| 81 |
|
| 82 |
-
reverse_iterator rbegin() noexcept;
|
| 83 |
-
const_reverse_iterator rbegin() const noexcept;
|
| 84 |
-
reverse_iterator rend() noexcept;
|
| 85 |
-
const_reverse_iterator rend() const noexcept;
|
| 86 |
|
| 87 |
-
const_iterator cbegin() const noexcept;
|
| 88 |
-
const_iterator cend() const noexcept;
|
| 89 |
-
const_reverse_iterator crbegin() const noexcept;
|
| 90 |
-
const_reverse_iterator crend() const noexcept;
|
| 91 |
|
| 92 |
// capacity
|
| 93 |
-
|
| 94 |
-
size_type size() const noexcept;
|
| 95 |
-
size_type max_size() const noexcept;
|
| 96 |
|
| 97 |
-
// modifiers
|
| 98 |
-
template<class... Args> pair<iterator, bool> emplace(Args&&... args);
|
| 99 |
-
template<class... Args>
|
| 100 |
-
|
| 101 |
-
pair<iterator,bool> insert(value_type&
|
| 102 |
-
iterator insert(
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
| 104 |
template<class InputIterator>
|
| 105 |
-
void insert(InputIterator first, InputIterator last);
|
| 106 |
template<container-compatible-range<value_type> R>
|
| 107 |
-
void insert_range(R&& rg);
|
| 108 |
-
void insert(initializer_list<value_type>);
|
| 109 |
|
| 110 |
-
node_type extract(const_iterator position);
|
| 111 |
-
node_type extract(const key_type& x);
|
| 112 |
-
template<class K> node_type extract(K&& x);
|
| 113 |
-
insert_return_type insert(node_type&& nh);
|
| 114 |
-
iterator insert(const_iterator hint, node_type&& nh);
|
| 115 |
|
| 116 |
-
iterator erase(iterator position)
|
| 117 |
requires (!same_as<iterator, const_iterator>);
|
| 118 |
-
iterator erase(const_iterator position);
|
| 119 |
-
size_type erase(const key_type& x);
|
| 120 |
-
template<class K> size_type erase(K&& x);
|
| 121 |
-
iterator erase(const_iterator first, const_iterator last);
|
| 122 |
-
void swap(set&)
|
| 123 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 124 |
is_nothrow_swappable_v<Compare>);
|
| 125 |
-
void clear() noexcept;
|
| 126 |
|
| 127 |
template<class C2>
|
| 128 |
-
void merge(set<Key, C2, Allocator>& source);
|
| 129 |
template<class C2>
|
| 130 |
-
void merge(set<Key, C2, Allocator>&& source);
|
| 131 |
template<class C2>
|
| 132 |
-
void merge(multiset<Key, C2, Allocator>& source);
|
| 133 |
template<class C2>
|
| 134 |
-
void merge(multiset<Key, C2, Allocator>&& source);
|
| 135 |
|
| 136 |
// observers
|
| 137 |
-
key_compare key_comp() const;
|
| 138 |
-
value_compare value_comp() const;
|
| 139 |
|
| 140 |
// set operations
|
| 141 |
-
iterator find(const key_type& x);
|
| 142 |
-
const_iterator find(const key_type& x) const;
|
| 143 |
-
template<class K> iterator find(const K& x);
|
| 144 |
-
template<class K> const_iterator find(const K& x) const;
|
| 145 |
|
| 146 |
-
size_type count(const key_type& x) const;
|
| 147 |
-
template<class K> size_type count(const K& x) const;
|
| 148 |
|
| 149 |
-
bool contains(const key_type& x) const;
|
| 150 |
-
template<class K> bool contains(const K& x) const;
|
| 151 |
|
| 152 |
-
iterator lower_bound(const key_type& x);
|
| 153 |
-
const_iterator lower_bound(const key_type& x) const;
|
| 154 |
-
template<class K> iterator lower_bound(const K& x);
|
| 155 |
-
template<class K> const_iterator lower_bound(const K& x) const;
|
| 156 |
|
| 157 |
-
iterator upper_bound(const key_type& x);
|
| 158 |
-
const_iterator upper_bound(const key_type& x) const;
|
| 159 |
-
template<class K> iterator upper_bound(const K& x);
|
| 160 |
-
template<class K> const_iterator upper_bound(const K& x) const;
|
| 161 |
|
| 162 |
-
pair<iterator, iterator> equal_range(const key_type& x);
|
| 163 |
-
pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
|
| 164 |
template<class K>
|
| 165 |
-
pair<iterator, iterator> equal_range(const K& x);
|
| 166 |
template<class K>
|
| 167 |
-
pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 168 |
};
|
| 169 |
|
| 170 |
template<class InputIterator,
|
| 171 |
class Compare = less<iter-value-type<InputIterator>>,
|
| 172 |
class Allocator = allocator<iter-value-type<InputIterator>>>
|
|
|
|
| 6 |
iterators.
|
| 7 |
|
| 8 |
A `set` meets all of the requirements of a container
|
| 9 |
[[container.reqmts]], of a reversible container
|
| 10 |
[[container.rev.reqmts]], of an allocator-aware container
|
| 11 |
+
[[container.alloc.reqmts]], and of an associative container
|
| 12 |
[[associative.reqmts]]. A `set` also provides most operations described
|
| 13 |
in [[associative.reqmts]] for unique keys. This means that a `set`
|
| 14 |
supports the `a_uniq` operations in [[associative.reqmts]] but not the
|
| 15 |
`a_eq` operations. For a `set<Key>` both the `key_type` and `value_type`
|
| 16 |
are `Key`. Descriptions are provided here only for operations on `set`
|
| 17 |
that are not described in one of these tables and for operations where
|
| 18 |
there is additional semantic information.
|
| 19 |
|
| 20 |
+
The types `iterator` and `const_iterator` meet the constexpr iterator
|
| 21 |
+
requirements [[iterator.requirements.general]].
|
| 22 |
+
|
| 23 |
``` cpp
|
| 24 |
namespace std {
|
| 25 |
template<class Key, class Compare = less<Key>,
|
| 26 |
class Allocator = allocator<Key>>
|
| 27 |
class set {
|
|
|
|
| 30 |
using key_type = Key;
|
| 31 |
using key_compare = Compare;
|
| 32 |
using value_type = Key;
|
| 33 |
using value_compare = Compare;
|
| 34 |
using allocator_type = Allocator;
|
| 35 |
+
using pointer = allocator_traits<Allocator>::pointer;
|
| 36 |
+
using const_pointer = allocator_traits<Allocator>::const_pointer;
|
| 37 |
using reference = value_type&;
|
| 38 |
using const_reference = const value_type&;
|
| 39 |
using size_type = implementation-defined // type of set::size_type; // see [container.requirements]
|
| 40 |
using difference_type = implementation-defined // type of set::difference_type; // see [container.requirements]
|
| 41 |
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
|
|
|
| 44 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 45 |
using node_type = unspecified;
|
| 46 |
using insert_return_type = insert-return-type<iterator, node_type>;
|
| 47 |
|
| 48 |
// [set.cons], construct/copy/destroy
|
| 49 |
+
constexpr set() : set(Compare()) { }
|
| 50 |
+
constexpr explicit set(const Compare& comp, const Allocator& = Allocator());
|
| 51 |
template<class InputIterator>
|
| 52 |
+
constexpr set(InputIterator first, InputIterator last,
|
| 53 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 54 |
template<container-compatible-range<value_type> R>
|
| 55 |
+
constexpr set(from_range_t, R&& rg,
|
| 56 |
+
const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 57 |
+
constexpr set(const set& x);
|
| 58 |
+
constexpr set(set&& x);
|
| 59 |
+
constexpr explicit set(const Allocator&);
|
| 60 |
+
constexpr set(const set&, const type_identity_t<Allocator>&);
|
| 61 |
+
constexpr set(set&&, const type_identity_t<Allocator>&);
|
| 62 |
+
constexpr set(initializer_list<value_type>,
|
| 63 |
+
const Compare& = Compare(), const Allocator& = Allocator());
|
| 64 |
template<class InputIterator>
|
| 65 |
+
constexpr set(InputIterator first, InputIterator last, const Allocator& a)
|
| 66 |
: set(first, last, Compare(), a) { }
|
| 67 |
template<container-compatible-range<value_type> R>
|
| 68 |
+
constexpr set(from_range_t, R&& rg, const Allocator& a)
|
| 69 |
: set(from_range, std::forward<R>(rg), Compare(), a) { }
|
| 70 |
+
constexpr set(initializer_list<value_type> il, const Allocator& a)
|
| 71 |
: set(il, Compare(), a) { }
|
| 72 |
+
constexpr ~set();
|
| 73 |
+
constexpr set& operator=(const set& x);
|
| 74 |
+
constexpr set& operator=(set&& x)
|
| 75 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 76 |
is_nothrow_move_assignable_v<Compare>);
|
| 77 |
+
constexpr set& operator=(initializer_list<value_type>);
|
| 78 |
+
constexpr allocator_type get_allocator() const noexcept;
|
| 79 |
|
| 80 |
// iterators
|
| 81 |
+
constexpr iterator begin() noexcept;
|
| 82 |
+
constexpr const_iterator begin() const noexcept;
|
| 83 |
+
constexpr iterator end() noexcept;
|
| 84 |
+
constexpr const_iterator end() const noexcept;
|
| 85 |
|
| 86 |
+
constexpr reverse_iterator rbegin() noexcept;
|
| 87 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 88 |
+
constexpr reverse_iterator rend() noexcept;
|
| 89 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 90 |
|
| 91 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 92 |
+
constexpr const_iterator cend() const noexcept;
|
| 93 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 94 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 95 |
|
| 96 |
// capacity
|
| 97 |
+
constexpr bool empty() const noexcept;
|
| 98 |
+
constexpr size_type size() const noexcept;
|
| 99 |
+
constexpr size_type max_size() const noexcept;
|
| 100 |
|
| 101 |
+
// [set.modifiers], modifiers
|
| 102 |
+
template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args);
|
| 103 |
+
template<class... Args>
|
| 104 |
+
constexpr iterator emplace_hint(const_iterator position, Args&&... args);
|
| 105 |
+
constexpr pair<iterator,bool> insert(const value_type& x);
|
| 106 |
+
constexpr pair<iterator,bool> insert(value_type&& x);
|
| 107 |
+
template<class K> constexpr pair<iterator, bool> insert(K&& x);
|
| 108 |
+
constexpr iterator insert(const_iterator position, const value_type& x);
|
| 109 |
+
constexpr iterator insert(const_iterator position, value_type&& x);
|
| 110 |
+
template<class K> constexpr iterator insert(const_iterator position, K&& x);
|
| 111 |
template<class InputIterator>
|
| 112 |
+
constexpr void insert(InputIterator first, InputIterator last);
|
| 113 |
template<container-compatible-range<value_type> R>
|
| 114 |
+
constexpr void insert_range(R&& rg);
|
| 115 |
+
constexpr void insert(initializer_list<value_type>);
|
| 116 |
|
| 117 |
+
constexpr node_type extract(const_iterator position);
|
| 118 |
+
constexpr node_type extract(const key_type& x);
|
| 119 |
+
template<class K> constexpr node_type extract(K&& x);
|
| 120 |
+
constexpr insert_return_type insert(node_type&& nh);
|
| 121 |
+
constexpr iterator insert(const_iterator hint, node_type&& nh);
|
| 122 |
|
| 123 |
+
constexpr iterator erase(iterator position)
|
| 124 |
requires (!same_as<iterator, const_iterator>);
|
| 125 |
+
constexpr iterator erase(const_iterator position);
|
| 126 |
+
constexpr size_type erase(const key_type& x);
|
| 127 |
+
template<class K> constexpr size_type erase(K&& x);
|
| 128 |
+
constexpr iterator erase(const_iterator first, const_iterator last);
|
| 129 |
+
constexpr void swap(set&)
|
| 130 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 131 |
is_nothrow_swappable_v<Compare>);
|
| 132 |
+
constexpr void clear() noexcept;
|
| 133 |
|
| 134 |
template<class C2>
|
| 135 |
+
constexpr void merge(set<Key, C2, Allocator>& source);
|
| 136 |
template<class C2>
|
| 137 |
+
constexpr void merge(set<Key, C2, Allocator>&& source);
|
| 138 |
template<class C2>
|
| 139 |
+
constexpr void merge(multiset<Key, C2, Allocator>& source);
|
| 140 |
template<class C2>
|
| 141 |
+
constexpr void merge(multiset<Key, C2, Allocator>&& source);
|
| 142 |
|
| 143 |
// observers
|
| 144 |
+
constexpr key_compare key_comp() const;
|
| 145 |
+
constexpr value_compare value_comp() const;
|
| 146 |
|
| 147 |
// set operations
|
| 148 |
+
constexpr iterator find(const key_type& x);
|
| 149 |
+
constexpr const_iterator find(const key_type& x) const;
|
| 150 |
+
template<class K> constexpr iterator find(const K& x);
|
| 151 |
+
template<class K> constexpr const_iterator find(const K& x) const;
|
| 152 |
|
| 153 |
+
constexpr size_type count(const key_type& x) const;
|
| 154 |
+
template<class K> constexpr size_type count(const K& x) const;
|
| 155 |
|
| 156 |
+
constexpr bool contains(const key_type& x) const;
|
| 157 |
+
template<class K> constexpr bool contains(const K& x) const;
|
| 158 |
|
| 159 |
+
constexpr iterator lower_bound(const key_type& x);
|
| 160 |
+
constexpr const_iterator lower_bound(const key_type& x) const;
|
| 161 |
+
template<class K> constexpr iterator lower_bound(const K& x);
|
| 162 |
+
template<class K> constexpr const_iterator lower_bound(const K& x) const;
|
| 163 |
|
| 164 |
+
constexpr iterator upper_bound(const key_type& x);
|
| 165 |
+
constexpr const_iterator upper_bound(const key_type& x) const;
|
| 166 |
+
template<class K> constexpr iterator upper_bound(const K& x);
|
| 167 |
+
template<class K> constexpr const_iterator upper_bound(const K& x) const;
|
| 168 |
|
| 169 |
+
constexpr pair<iterator, iterator> equal_range(const key_type& x);
|
| 170 |
+
constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
|
| 171 |
template<class K>
|
| 172 |
+
constexpr pair<iterator, iterator> equal_range(const K& x);
|
| 173 |
template<class K>
|
| 174 |
+
constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const;
|
| 175 |
};
|
| 176 |
|
| 177 |
template<class InputIterator,
|
| 178 |
class Compare = less<iter-value-type<InputIterator>>,
|
| 179 |
class Allocator = allocator<iter-value-type<InputIterator>>>
|