tmp/tmpqwp59gbv/{from.md → to.md}
RENAMED
|
@@ -1,21 +1,23 @@
|
|
| 1 |
#### Overview <a id="set.overview">[[set.overview]]</a>
|
| 2 |
|
| 3 |
-
A `set` is an associative container that supports unique keys (
|
| 4 |
-
at most one of each key value) and provides for fast retrieval
|
| 5 |
-
keys themselves. The `set` class supports bidirectional
|
|
|
|
| 6 |
|
| 7 |
-
A `set` meets all of the requirements of a container
|
| 8 |
-
|
| 9 |
-
[[
|
| 10 |
-
[[container.alloc.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
`
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
``` cpp
|
| 19 |
namespace std {
|
| 20 |
template<class Key, class Compare = less<Key>,
|
| 21 |
class Allocator = allocator<Key>>
|
|
@@ -29,12 +31,12 @@ namespace std {
|
|
| 29 |
using allocator_type = Allocator;
|
| 30 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 31 |
using const_pointer = typename allocator_traits<Allocator>::const_pointer;
|
| 32 |
using reference = value_type&;
|
| 33 |
using const_reference = const value_type&;
|
| 34 |
-
using size_type = implementation-defined; // see [container.requirements]
|
| 35 |
-
using difference_type = implementation-defined; // see [container.requirements]
|
| 36 |
using iterator = implementation-defined // type of set::iterator; // see [container.requirements]
|
| 37 |
using const_iterator = implementation-defined // type of set::const_iterator; // see [container.requirements]
|
| 38 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 39 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 40 |
using node_type = unspecified;
|
|
@@ -44,20 +46,25 @@ namespace std {
|
|
| 44 |
set() : set(Compare()) { }
|
| 45 |
explicit set(const Compare& comp, const Allocator& = Allocator());
|
| 46 |
template<class InputIterator>
|
| 47 |
set(InputIterator first, InputIterator last,
|
| 48 |
const Compare& comp = Compare(), const Allocator& = Allocator());
|
|
|
|
|
|
|
| 49 |
set(const set& x);
|
| 50 |
set(set&& x);
|
| 51 |
explicit set(const Allocator&);
|
| 52 |
-
set(const set&, const Allocator&);
|
| 53 |
-
set(set&&, const Allocator&);
|
| 54 |
set(initializer_list<value_type>, const Compare& = Compare(),
|
| 55 |
const Allocator& = Allocator());
|
| 56 |
template<class InputIterator>
|
| 57 |
set(InputIterator first, InputIterator last, const Allocator& a)
|
| 58 |
: set(first, last, Compare(), a) { }
|
|
|
|
|
|
|
|
|
|
| 59 |
set(initializer_list<value_type> il, const Allocator& a)
|
| 60 |
: set(il, Compare(), a) { }
|
| 61 |
~set();
|
| 62 |
set& operator=(const set& x);
|
| 63 |
set& operator=(set&& x)
|
|
@@ -94,20 +101,25 @@ namespace std {
|
|
| 94 |
pair<iterator,bool> insert(value_type&& x);
|
| 95 |
iterator insert(const_iterator position, const value_type& x);
|
| 96 |
iterator insert(const_iterator position, value_type&& x);
|
| 97 |
template<class InputIterator>
|
| 98 |
void insert(InputIterator first, InputIterator last);
|
|
|
|
|
|
|
| 99 |
void insert(initializer_list<value_type>);
|
| 100 |
|
| 101 |
node_type extract(const_iterator position);
|
| 102 |
node_type extract(const key_type& x);
|
|
|
|
| 103 |
insert_return_type insert(node_type&& nh);
|
| 104 |
iterator insert(const_iterator hint, node_type&& nh);
|
| 105 |
|
| 106 |
-
iterator erase(iterator position)
|
|
|
|
| 107 |
iterator erase(const_iterator position);
|
| 108 |
size_type erase(const key_type& x);
|
|
|
|
| 109 |
iterator erase(const_iterator first, const_iterator last);
|
| 110 |
void swap(set&)
|
| 111 |
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
|
| 112 |
is_nothrow_swappable_v<Compare>);
|
| 113 |
void clear() noexcept;
|
|
@@ -160,25 +172,28 @@ namespace std {
|
|
| 160 |
class Allocator = allocator<iter-value-type<InputIterator>>>
|
| 161 |
set(InputIterator, InputIterator,
|
| 162 |
Compare = Compare(), Allocator = Allocator())
|
| 163 |
-> set<iter-value-type<InputIterator>, Compare, Allocator>;
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 166 |
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 167 |
-> set<Key, Compare, Allocator>;
|
| 168 |
|
| 169 |
template<class InputIterator, class Allocator>
|
| 170 |
set(InputIterator, InputIterator, Allocator)
|
| 171 |
-> set<iter-value-type<InputIterator>,
|
| 172 |
less<iter-value-type<InputIterator>>, Allocator>;
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
template<class Key, class Allocator>
|
| 175 |
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
|
| 176 |
-
|
| 177 |
-
// swap
|
| 178 |
-
template<class Key, class Compare, class Allocator>
|
| 179 |
-
void swap(set<Key, Compare, Allocator>& x,
|
| 180 |
-
set<Key, Compare, Allocator>& y)
|
| 181 |
-
noexcept(noexcept(x.swap(y)));
|
| 182 |
}
|
| 183 |
```
|
| 184 |
|
|
|
|
| 1 |
#### Overview <a id="set.overview">[[set.overview]]</a>
|
| 2 |
|
| 3 |
+
A `set` is an associative container that supports unique keys (i.e.,
|
| 4 |
+
contains at most one of each key value) and provides for fast retrieval
|
| 5 |
+
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]]. 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 |
``` cpp
|
| 21 |
namespace std {
|
| 22 |
template<class Key, class Compare = less<Key>,
|
| 23 |
class Allocator = allocator<Key>>
|
|
|
|
| 31 |
using allocator_type = Allocator;
|
| 32 |
using pointer = typename allocator_traits<Allocator>::pointer;
|
| 33 |
using const_pointer = typename allocator_traits<Allocator>::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]
|
| 39 |
using const_iterator = implementation-defined // type of set::const_iterator; // see [container.requirements]
|
| 40 |
using reverse_iterator = std::reverse_iterator<iterator>;
|
| 41 |
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
| 42 |
using node_type = unspecified;
|
|
|
|
| 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, const Compare& comp = Compare(), const Allocator& = Allocator());
|
| 53 |
set(const set& x);
|
| 54 |
set(set&& x);
|
| 55 |
explicit set(const Allocator&);
|
| 56 |
+
set(const set&, const type_identity_t<Allocator>&);
|
| 57 |
+
set(set&&, const type_identity_t<Allocator>&);
|
| 58 |
set(initializer_list<value_type>, const Compare& = Compare(),
|
| 59 |
const Allocator& = Allocator());
|
| 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)
|
|
|
|
| 101 |
pair<iterator,bool> insert(value_type&& x);
|
| 102 |
iterator insert(const_iterator position, const value_type& x);
|
| 103 |
iterator insert(const_iterator position, value_type&& x);
|
| 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;
|
|
|
|
| 172 |
class Allocator = allocator<iter-value-type<InputIterator>>>
|
| 173 |
set(InputIterator, InputIterator,
|
| 174 |
Compare = Compare(), Allocator = Allocator())
|
| 175 |
-> set<iter-value-type<InputIterator>, Compare, Allocator>;
|
| 176 |
|
| 177 |
+
template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>,
|
| 178 |
+
class Allocator = allocator<ranges::range_value_t<R>>>
|
| 179 |
+
set(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
|
| 180 |
+
-> set<ranges::range_value_t<R>, Compare, Allocator>;
|
| 181 |
+
|
| 182 |
template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>>
|
| 183 |
set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator())
|
| 184 |
-> set<Key, Compare, Allocator>;
|
| 185 |
|
| 186 |
template<class InputIterator, class Allocator>
|
| 187 |
set(InputIterator, InputIterator, Allocator)
|
| 188 |
-> set<iter-value-type<InputIterator>,
|
| 189 |
less<iter-value-type<InputIterator>>, Allocator>;
|
| 190 |
|
| 191 |
+
template<ranges::input_range R, class Allocator>
|
| 192 |
+
set(from_range_t, R&&, Allocator)
|
| 193 |
+
-> set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>;
|
| 194 |
+
|
| 195 |
template<class Key, class Allocator>
|
| 196 |
set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
}
|
| 198 |
```
|
| 199 |
|