From Jason Turner

[map.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmps0p0egzv/{from.md → to.md} +38 -24
tmp/tmps0p0egzv/{from.md → to.md} RENAMED
@@ -1,22 +1,23 @@
1
  #### Overview <a id="map.overview">[[map.overview]]</a>
2
 
3
- A `map` is an associative container that supports unique keys (contains
4
- at most one of each key value) and provides for fast retrieval of values
5
- of another type `T` based on the keys. The `map` class supports
6
- bidirectional iterators.
7
 
8
- A `map` meets all of the requirements of a container, of a reversible
9
- container [[container.requirements]], of an associative container
10
- [[associative.reqmts]], and of an allocator-aware container (
11
- [[container.alloc.req]]). A `map` also provides most operations
12
- described in  [[associative.reqmts]] for unique keys. This means that a
13
- `map` supports the `a_uniq` operations in  [[associative.reqmts]] but
14
- not the `a_eq` operations. For a `map<Key,T>` the `key_type` is `Key`
15
- and the `value_type` is `pair<const Key,T>`. Descriptions are provided
16
- here only for operations on `map` that are not described in one of those
17
- tables or for operations where there is additional semantic information.
 
18
 
19
  ``` cpp
20
  namespace std {
21
  template<class Key, class T, class Compare = less<Key>,
22
  class Allocator = allocator<pair<const Key, T>>>
@@ -30,12 +31,12 @@ namespace std {
30
  using allocator_type = Allocator;
31
  using pointer = typename allocator_traits<Allocator>::pointer;
32
  using const_pointer = typename allocator_traits<Allocator>::const_pointer;
33
  using reference = value_type&;
34
  using const_reference = const value_type&;
35
- using size_type = implementation-defined; // see [container.requirements]
36
- using difference_type = implementation-defined; // see [container.requirements]
37
  using iterator = implementation-defined // type of map::iterator; // see [container.requirements]
38
  using const_iterator = implementation-defined // type of map::const_iterator; // see [container.requirements]
39
  using reverse_iterator = std::reverse_iterator<iterator>;
40
  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
41
  using node_type = unspecified;
@@ -44,10 +45,11 @@ namespace std {
44
  class value_compare {
45
  friend class map;
46
  protected:
47
  Compare comp;
48
  value_compare(Compare c) : comp(c) {}
 
49
  public:
50
  bool operator()(const value_type& x, const value_type& y) const {
51
  return comp(x.first, y.first);
52
  }
53
  };
@@ -56,21 +58,26 @@ namespace std {
56
  map() : map(Compare()) { }
57
  explicit map(const Compare& comp, const Allocator& = Allocator());
58
  template<class InputIterator>
59
  map(InputIterator first, InputIterator last,
60
  const Compare& comp = Compare(), const Allocator& = Allocator());
 
 
61
  map(const map& x);
62
  map(map&& x);
63
  explicit map(const Allocator&);
64
- map(const map&, const Allocator&);
65
- map(map&&, const Allocator&);
66
  map(initializer_list<value_type>,
67
  const Compare& = Compare(),
68
  const Allocator& = Allocator());
69
  template<class InputIterator>
70
  map(InputIterator first, InputIterator last, const Allocator& a)
71
  : map(first, last, Compare(), a) { }
 
 
 
72
  map(initializer_list<value_type> il, const Allocator& a)
73
  : map(il, Compare(), a) { }
74
  ~map();
75
  map& operator=(const map& x);
76
  map& operator=(map&& x)
@@ -116,14 +123,17 @@ namespace std {
116
  iterator insert(const_iterator position, value_type&& x);
117
  template<class P>
118
  iterator insert(const_iterator position, P&&);
119
  template<class InputIterator>
120
  void insert(InputIterator first, InputIterator last);
 
 
121
  void insert(initializer_list<value_type>);
122
 
123
  node_type extract(const_iterator position);
124
  node_type extract(const key_type& x);
 
125
  insert_return_type insert(node_type&& nh);
126
  iterator insert(const_iterator hint, node_type&& nh);
127
 
128
  template<class... Args>
129
  pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
@@ -143,10 +153,11 @@ namespace std {
143
  iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
144
 
145
  iterator erase(iterator position);
146
  iterator erase(const_iterator position);
147
  size_type erase(const key_type& x);
 
148
  iterator erase(const_iterator first, const_iterator last);
149
  void swap(map&)
150
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
151
  is_nothrow_swappable_v<Compare>);
152
  void clear() noexcept;
@@ -197,26 +208,29 @@ namespace std {
197
  template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>,
198
  class Allocator = allocator<iter-to-alloc-type<InputIterator>>>
199
  map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
200
  -> map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare, Allocator>;
201
 
 
 
 
 
 
202
  template<class Key, class T, class Compare = less<Key>,
203
  class Allocator = allocator<pair<const Key, T>>>
204
  map(initializer_list<pair<Key, T>>, Compare = Compare(), Allocator = Allocator())
205
  -> map<Key, T, Compare, Allocator>;
206
 
207
  template<class InputIterator, class Allocator>
208
  map(InputIterator, InputIterator, Allocator)
209
  -> map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>,
210
  less<iter-key-type<InputIterator>>, Allocator>;
211
 
 
 
 
 
212
  template<class Key, class T, class Allocator>
213
  map(initializer_list<pair<Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
214
-
215
- // swap
216
- template<class Key, class T, class Compare, class Allocator>
217
- void swap(map<Key, T, Compare, Allocator>& x,
218
- map<Key, T, Compare, Allocator>& y)
219
- noexcept(noexcept(x.swap(y)));
220
  }
221
  ```
222
 
 
1
  #### Overview <a id="map.overview">[[map.overview]]</a>
2
 
3
+ A `map` 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 values of another type `T` based on the keys. The `map` class
6
+ supports bidirectional iterators.
7
 
8
+ A `map` 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 `map` also provides most operations described
13
+ in  [[associative.reqmts]] for unique keys. This means that a `map`
14
+ supports the `a_uniq` operations in  [[associative.reqmts]] but not the
15
+ `a_eq` operations. For a `map<Key,T>` the `key_type` is `Key` and the
16
+ `value_type` is `pair<const Key,T>`. Descriptions are provided here only
17
+ for operations on `map` that are not described in one of those tables or
18
+ for operations where there is additional semantic information.
19
 
20
  ``` cpp
21
  namespace std {
22
  template<class Key, class T, class Compare = less<Key>,
23
  class Allocator = allocator<pair<const Key, T>>>
 
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 map::size_type; // see [container.requirements]
37
+ using difference_type = implementation-defined // type of map::difference_type; // see [container.requirements]
38
  using iterator = implementation-defined // type of map::iterator; // see [container.requirements]
39
  using const_iterator = implementation-defined // type of map::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;
 
45
  class value_compare {
46
  friend class map;
47
  protected:
48
  Compare comp;
49
  value_compare(Compare c) : comp(c) {}
50
+
51
  public:
52
  bool operator()(const value_type& x, const value_type& y) const {
53
  return comp(x.first, y.first);
54
  }
55
  };
 
58
  map() : map(Compare()) { }
59
  explicit map(const Compare& comp, const Allocator& = Allocator());
60
  template<class InputIterator>
61
  map(InputIterator first, InputIterator last,
62
  const Compare& comp = Compare(), const Allocator& = Allocator());
63
+ template<container-compatible-range<value_type> R>
64
+ map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator());
65
  map(const map& x);
66
  map(map&& x);
67
  explicit map(const Allocator&);
68
+ map(const map&, const type_identity_t<Allocator>&);
69
+ map(map&&, const type_identity_t<Allocator>&);
70
  map(initializer_list<value_type>,
71
  const Compare& = Compare(),
72
  const Allocator& = Allocator());
73
  template<class InputIterator>
74
  map(InputIterator first, InputIterator last, const Allocator& a)
75
  : map(first, last, Compare(), a) { }
76
+ template<container-compatible-range<value_type> R>
77
+ map(from_range_t, R&& rg, const Allocator& a))
78
+ : map(from_range, std::forward<R>(rg), Compare(), a) { }
79
  map(initializer_list<value_type> il, const Allocator& a)
80
  : map(il, Compare(), a) { }
81
  ~map();
82
  map& operator=(const map& x);
83
  map& operator=(map&& x)
 
123
  iterator insert(const_iterator position, value_type&& x);
124
  template<class P>
125
  iterator insert(const_iterator position, P&&);
126
  template<class InputIterator>
127
  void insert(InputIterator first, InputIterator last);
128
+ template<container-compatible-range<value_type> R>
129
+ void insert_range(R&& rg);
130
  void insert(initializer_list<value_type>);
131
 
132
  node_type extract(const_iterator position);
133
  node_type extract(const key_type& x);
134
+ template<class K> node_type extract(K&& x);
135
  insert_return_type insert(node_type&& nh);
136
  iterator insert(const_iterator hint, node_type&& nh);
137
 
138
  template<class... Args>
139
  pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
 
153
  iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
154
 
155
  iterator erase(iterator position);
156
  iterator erase(const_iterator position);
157
  size_type erase(const key_type& x);
158
+ template<class K> size_type erase(K&& x);
159
  iterator erase(const_iterator first, const_iterator last);
160
  void swap(map&)
161
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
162
  is_nothrow_swappable_v<Compare>);
163
  void clear() noexcept;
 
208
  template<class InputIterator, class Compare = less<iter-key-type<InputIterator>>,
209
  class Allocator = allocator<iter-to-alloc-type<InputIterator>>>
210
  map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
211
  -> map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>, Compare, Allocator>;
212
 
213
+ template<ranges::input_range R, class Compare = less<range-key-type<R>,
214
+ class Allocator = allocator<range-to-alloc-type<R>>>
215
+ map(from_range_t, R&&, Compare = Compare(), Allocator = Allocator())
216
+ -> map<range-key-type<R>, range-mapped-type<R>, Compare, Allocator>;
217
+
218
  template<class Key, class T, class Compare = less<Key>,
219
  class Allocator = allocator<pair<const Key, T>>>
220
  map(initializer_list<pair<Key, T>>, Compare = Compare(), Allocator = Allocator())
221
  -> map<Key, T, Compare, Allocator>;
222
 
223
  template<class InputIterator, class Allocator>
224
  map(InputIterator, InputIterator, Allocator)
225
  -> map<iter-key-type<InputIterator>, iter-mapped-type<InputIterator>,
226
  less<iter-key-type<InputIterator>>, Allocator>;
227
 
228
+ template<ranges::input_range R, class Allocator>
229
+ map(from_range_t, R&&, Allocator)
230
+ -> map<range-key-type<R>, range-mapped-type<R>, less<range-key-type<R>>, Allocator>;
231
+
232
  template<class Key, class T, class Allocator>
233
  map(initializer_list<pair<Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
 
 
 
 
 
 
234
  }
235
  ```
236