From Jason Turner

[map]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpg207do9k/{from.md → to.md} +41 -55
tmp/tmpg207do9k/{from.md → to.md} RENAMED
@@ -55,28 +55,32 @@ namespace std {
55
  return comp(x.first, y.first);
56
  }
57
  };
58
 
59
  // [map.cons], construct/copy/destroy:
60
- explicit map(const Compare& comp = Compare(),
 
61
  const Allocator& = Allocator());
62
  template <class InputIterator>
63
  map(InputIterator first, InputIterator last,
64
  const Compare& comp = Compare(), const Allocator& = Allocator());
65
- map(const map<Key,T,Compare,Allocator>& x);
66
- map(map<Key,T,Compare,Allocator>&& x);
67
  explicit map(const Allocator&);
68
  map(const map&, const Allocator&);
69
  map(map&&, const Allocator&);
70
  map(initializer_list<value_type>,
71
  const Compare& = Compare(),
72
  const Allocator& = Allocator());
 
 
 
 
 
73
  ~map();
74
- map<Key,T,Compare,Allocator>&
75
- operator=(const map<Key,T,Compare,Allocator>& x);
76
- map<Key,T,Compare,Allocator>&
77
- operator=(map<Key,T,Compare,Allocator>&& x);
78
  map& operator=(initializer_list<value_type>);
79
  allocator_type get_allocator() const noexcept;
80
 
81
  // iterators:
82
  iterator begin() noexcept;
@@ -118,31 +122,44 @@ namespace std {
118
  void insert(initializer_list<value_type>);
119
 
120
  iterator erase(const_iterator position);
121
  size_type erase(const key_type& x);
122
  iterator erase(const_iterator first, const_iterator last);
123
- void swap(map<Key,T,Compare,Allocator>&);
124
  void clear() noexcept;
125
 
126
  // observers:
127
  key_compare key_comp() const;
128
  value_compare value_comp() const;
129
 
130
- // [map.ops], map operations:
131
  iterator find(const key_type& x);
132
  const_iterator find(const key_type& x) const;
 
 
 
133
  size_type count(const key_type& x) const;
 
134
 
135
  iterator lower_bound(const key_type& x);
136
  const_iterator lower_bound(const key_type& x) const;
 
 
 
137
  iterator upper_bound(const key_type& x);
138
  const_iterator upper_bound(const key_type& x) const;
 
 
139
 
140
  pair<iterator,iterator>
141
  equal_range(const key_type& x);
142
  pair<const_iterator,const_iterator>
143
  equal_range(const key_type& x) const;
 
 
 
 
144
  };
145
 
146
  template <class Key, class T, class Compare, class Allocator>
147
  bool operator==(const map<Key,T,Compare,Allocator>& x,
148
  const map<Key,T,Compare,Allocator>& y);
@@ -170,11 +187,11 @@ namespace std {
170
  ```
171
 
172
  #### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
173
 
174
  ``` cpp
175
- explicit map(const Compare& comp = Compare(),
176
  const Allocator& = Allocator());
177
  ```
178
 
179
  *Effects:* Constructs an empty `map` using the specified comparison
180
  object and allocator.
@@ -185,13 +202,13 @@ object and allocator.
185
  template <class InputIterator>
186
  map(InputIterator first, InputIterator last,
187
  const Compare& comp = Compare(), const Allocator& = Allocator());
188
  ```
189
 
190
- *Requires:* If the iterator’s dereference operator returns an lvalue or
191
  a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
192
- `mapped_type` shall be `CopyConstructible`.
193
 
194
  *Effects:* Constructs an empty `map` using the specified comparison
195
  object and allocator, and inserts elements from the range \[`first`,
196
  `last`).
197
 
@@ -205,31 +222,31 @@ T& operator[](const key_type& x);
205
  ```
206
 
207
  *Effects:* If there is no key equivalent to `x` in the map, inserts
208
  `value_type(x, T())` into the map.
209
 
210
- *Requires:* `key_type` shall be `CopyConstructible` and `mapped_type`
211
- shall be `DefaultConstructible`.
212
 
213
  *Returns:* A reference to the `mapped_type` corresponding to `x` in
214
  `*this`.
215
 
216
- *Complexity:* logarithmic.
217
 
218
  ``` cpp
219
  T& operator[](key_type&& x);
220
  ```
221
 
222
  *Effects:* If there is no key equivalent to `x` in the map, inserts
223
  `value_type(std::move(x), T())` into the map.
224
 
225
- *Requires:* `mapped_type` shall be `DefaultConstructible`.
226
 
227
  *Returns:* A reference to the `mapped_type` corresponding to `x` in
228
  `*this`.
229
 
230
- *Complexity:* logarithmic.
231
 
232
  ``` cpp
233
  T& at(const key_type& x);
234
  const T& at(const key_type& x) const;
235
  ```
@@ -238,58 +255,27 @@ const T& at(const key_type& x) const;
238
  `*this`.
239
 
240
  *Throws:* An exception object of type `out_of_range` if no such element
241
  is present.
242
 
243
- *Complexity:* logarithmic.
244
 
245
  #### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
246
 
247
  ``` cpp
248
  template <class P> pair<iterator, bool> insert(P&& x);
249
- template <class P> pair<iterator, bool> insert(const_iterator position, P&& x);
250
  template <class InputIterator>
251
  void insert(InputIterator first, InputIterator last);
252
  ```
253
 
254
- *Requires:* `P` shall be convertible to `value_type`.
 
 
255
 
256
- If `P` is instantiated as a reference type, then the argument `x` is
257
- copied from. Otherwise `x` is considered to be an rvalue as it is
258
- converted to `value_type` and inserted into the `map`. Specifically, in
259
- such cases `CopyConstructible` is not required of `key_type` or
260
- `mapped_type` unless the conversion from `P` specifically requires it
261
- (e.g., if `P` is a `tuple<const key_type, mapped_type>`, then `key_type`
262
- must be `CopyConstructible`). The signature taking `InputIterator`
263
- parameters does not require `CopyConstructible` of either `key_type` or
264
- `mapped_type` if the dereferenced `InputIterator` returns a non-const
265
- rvalue `pair<key_type,mapped_type>`. Otherwise `CopyConstructible` is
266
- required for both `key_type` and `mapped_type`.
267
-
268
- #### `map` operations <a id="map.ops">[[map.ops]]</a>
269
-
270
- ``` cpp
271
- iterator find(const key_type& x);
272
- const_iterator find(const key_type& x) const;
273
-
274
- iterator lower_bound(const key_type& x);
275
- const_iterator lower_bound(const key_type& x) const;
276
-
277
- iterator upper_bound(const key_type& x);
278
- const_iterator upper_bound(const key_type &x) const;
279
-
280
- pair<iterator, iterator>
281
- equal_range(const key_type &x);
282
- pair<const_iterator, const_iterator>
283
- equal_range(const key_type& x) const;
284
- ```
285
-
286
- The `find`, `lower_bound`, `upper_bound` and `equal_range` member
287
- functions each have two versions, one const and the other non-const. In
288
- each case the behavior of the two functions is identical except that the
289
- const version returns a `const_iterator` and the non-const version an
290
- `iterator` ([[associative.reqmts]]).
291
 
292
  #### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
293
 
294
  ``` cpp
295
  template <class Key, class T, class Compare, class Allocator>
 
55
  return comp(x.first, y.first);
56
  }
57
  };
58
 
59
  // [map.cons], construct/copy/destroy:
60
+ map() : map(Compare()) { }
61
+ explicit map(const Compare& comp,
62
  const Allocator& = Allocator());
63
  template <class InputIterator>
64
  map(InputIterator first, InputIterator last,
65
  const Compare& comp = Compare(), const Allocator& = Allocator());
66
+ map(const map& x);
67
+ map(map&& x);
68
  explicit map(const Allocator&);
69
  map(const map&, const Allocator&);
70
  map(map&&, const Allocator&);
71
  map(initializer_list<value_type>,
72
  const Compare& = Compare(),
73
  const Allocator& = Allocator());
74
+ template <class InputIterator>
75
+ map(InputIterator first, InputIterator last, const Allocator& a)
76
+ : map(first, last, Compare(), a) { }
77
+ map(initializer_list<value_type> il, const Allocator& a)
78
+ : map(il, Compare(), a) { }
79
  ~map();
80
+ map& operator=(const map& x);
81
+ map& operator=(map&& x);
 
 
82
  map& operator=(initializer_list<value_type>);
83
  allocator_type get_allocator() const noexcept;
84
 
85
  // iterators:
86
  iterator begin() noexcept;
 
122
  void insert(initializer_list<value_type>);
123
 
124
  iterator erase(const_iterator position);
125
  size_type erase(const key_type& x);
126
  iterator erase(const_iterator first, const_iterator last);
127
+ void swap(map&);
128
  void clear() noexcept;
129
 
130
  // observers:
131
  key_compare key_comp() const;
132
  value_compare value_comp() const;
133
 
134
+ // map operations:
135
  iterator find(const key_type& x);
136
  const_iterator find(const key_type& x) const;
137
+ template <class K> iterator find(const K& x);
138
+ template <class K> const_iterator find(const K& x) const;
139
+
140
  size_type count(const key_type& x) const;
141
+ template <class K> size_type count(const K& x) const;
142
 
143
  iterator lower_bound(const key_type& x);
144
  const_iterator lower_bound(const key_type& x) const;
145
+ template <class K> iterator lower_bound(const K& x);
146
+ template <class K> const_iterator lower_bound(const K& x) const;
147
+
148
  iterator upper_bound(const key_type& x);
149
  const_iterator upper_bound(const key_type& x) const;
150
+ template <class K> iterator upper_bound(const K& x);
151
+ template <class K> const_iterator upper_bound(const K& x) const;
152
 
153
  pair<iterator,iterator>
154
  equal_range(const key_type& x);
155
  pair<const_iterator,const_iterator>
156
  equal_range(const key_type& x) const;
157
+ template <class K>
158
+ pair<iterator, iterator> equal_range(const K& x);
159
+ template <class K>
160
+ pair<const_iterator, const_iterator> equal_range(const K& x) const;
161
  };
162
 
163
  template <class Key, class T, class Compare, class Allocator>
164
  bool operator==(const map<Key,T,Compare,Allocator>& x,
165
  const map<Key,T,Compare,Allocator>& y);
 
187
  ```
188
 
189
  #### `map` constructors, copy, and assignment <a id="map.cons">[[map.cons]]</a>
190
 
191
  ``` cpp
192
+ explicit map(const Compare& comp,
193
  const Allocator& = Allocator());
194
  ```
195
 
196
  *Effects:* Constructs an empty `map` using the specified comparison
197
  object and allocator.
 
202
  template <class InputIterator>
203
  map(InputIterator first, InputIterator last,
204
  const Compare& comp = Compare(), const Allocator& = Allocator());
205
  ```
206
 
207
+ *Requires:* If the iterator’s indirection operator returns an lvalue or
208
  a const rvalue `pair<key_type, mapped_type>`, then both `key_type` and
209
+ `mapped_type` shall be `CopyInsertable` into `*this`.
210
 
211
  *Effects:* Constructs an empty `map` using the specified comparison
212
  object and allocator, and inserts elements from the range \[`first`,
213
  `last`).
214
 
 
222
  ```
223
 
224
  *Effects:* If there is no key equivalent to `x` in the map, inserts
225
  `value_type(x, T())` into the map.
226
 
227
+ *Requires:* `key_type` shall be `CopyInsertable` and `mapped_type` shall
228
+ be `DefaultInsertable` into `*this`.
229
 
230
  *Returns:* A reference to the `mapped_type` corresponding to `x` in
231
  `*this`.
232
 
233
+ *Complexity:* Logarithmic.
234
 
235
  ``` cpp
236
  T& operator[](key_type&& x);
237
  ```
238
 
239
  *Effects:* If there is no key equivalent to `x` in the map, inserts
240
  `value_type(std::move(x), T())` into the map.
241
 
242
+ *Requires:* `mapped_type` shall be `DefaultInsertable` into `*this`.
243
 
244
  *Returns:* A reference to the `mapped_type` corresponding to `x` in
245
  `*this`.
246
 
247
+ *Complexity:* Logarithmic.
248
 
249
  ``` cpp
250
  T& at(const key_type& x);
251
  const T& at(const key_type& x) const;
252
  ```
 
255
  `*this`.
256
 
257
  *Throws:* An exception object of type `out_of_range` if no such element
258
  is present.
259
 
260
+ *Complexity:* Logarithmic.
261
 
262
  #### `map` modifiers <a id="map.modifiers">[[map.modifiers]]</a>
263
 
264
  ``` cpp
265
  template <class P> pair<iterator, bool> insert(P&& x);
266
+ template <class P> iterator insert(const_iterator position, P&& x);
267
  template <class InputIterator>
268
  void insert(InputIterator first, InputIterator last);
269
  ```
270
 
271
+ *Effects:* The first form is equivalent to
272
+ `return emplace(std::forward<P>(x))`. The second form is equivalent to
273
+ `return emplace_hint(position, std::forward<P>(x))`.
274
 
275
+ *Remarks:* These signatures shall not participate in overload resolution
276
+ unless `std::is_constructible<value_type, P&&>::value` is `true`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
 
278
  #### `map` specialized algorithms <a id="map.special">[[map.special]]</a>
279
 
280
  ``` cpp
281
  template <class Key, class T, class Compare, class Allocator>