From Jason Turner

[map.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjmofxgcf/{from.md → to.md} +33 -50
tmp/tmpjmofxgcf/{from.md → to.md} RENAMED
@@ -1,31 +1,30 @@
1
- #### Class template `map` 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` satisfies all of the requirements of a container, of a
9
- reversible container ([[container.requirements]]), of an associative
10
- container ([[associative.reqmts]]), and of an allocator-aware container
11
- (Table  [[tab:containers.allocatoraware]]). A `map` also provides most
12
- operations described in  [[associative.reqmts]] for unique keys. This
13
- means that a `map` supports the `a_uniq` operations in 
14
- [[associative.reqmts]] but not the `a_eq` operations. For a `map<Key,T>`
15
- the `key_type` is `Key` and the `value_type` is `pair<const Key,T>`.
16
- Descriptions are provided here only for operations on `map` that are not
17
- described in one of those tables or for operations where there is
18
- 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>>>
24
  class map {
25
  public:
26
- // types:
27
  using key_type = Key;
28
  using mapped_type = T;
29
  using value_type = pair<const Key, T>;
30
  using key_compare = Compare;
31
  using allocator_type = Allocator;
@@ -38,11 +37,11 @@ namespace std {
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;
43
- using insert_return_type = INSERT_RETURN_TYPE<iterator, node_type>;
44
 
45
  class value_compare {
46
  friend class map;
47
  protected:
48
  Compare comp;
@@ -78,11 +77,11 @@ namespace std {
78
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
79
  is_nothrow_move_assignable_v<Compare>);
80
  map& operator=(initializer_list<value_type>);
81
  allocator_type get_allocator() const noexcept;
82
 
83
- // iterators:
84
  iterator begin() noexcept;
85
  const_iterator begin() const noexcept;
86
  iterator end() noexcept;
87
  const_iterator end() const noexcept;
88
 
@@ -94,20 +93,20 @@ namespace std {
94
  const_iterator cbegin() const noexcept;
95
  const_iterator cend() const noexcept;
96
  const_reverse_iterator crbegin() const noexcept;
97
  const_reverse_iterator crend() const noexcept;
98
 
99
- // capacity:
100
- bool empty() const noexcept;
101
  size_type size() const noexcept;
102
  size_type max_size() const noexcept;
103
 
104
  // [map.access], element access
105
- T& operator[](const key_type& x);
106
- T& operator[](key_type&& x);
107
- T& at(const key_type& x);
108
- const T& at(const key_type& x) const;
109
 
110
  // [map.modifiers], modifiers
111
  template<class... Args> pair<iterator, bool> emplace(Args&&... args);
112
  template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
113
  pair<iterator, bool> insert(const value_type& x);
@@ -159,23 +158,26 @@ namespace std {
159
  template<class C2>
160
  void merge(multimap<Key, T, C2, Allocator>& source);
161
  template<class C2>
162
  void merge(multimap<Key, T, C2, Allocator>&& source);
163
 
164
- // observers:
165
  key_compare key_comp() const;
166
  value_compare value_comp() const;
167
 
168
- // map operations:
169
  iterator find(const key_type& x);
170
  const_iterator find(const key_type& x) const;
171
  template<class K> iterator find(const K& x);
172
  template<class K> const_iterator find(const K& x) const;
173
 
174
  size_type count(const key_type& x) const;
175
  template<class K> size_type count(const K& x) const;
176
 
 
 
 
177
  iterator lower_bound(const key_type& x);
178
  const_iterator lower_bound(const key_type& x) const;
179
  template<class K> iterator lower_bound(const K& x);
180
  template<class K> const_iterator lower_bound(const K& x) const;
181
 
@@ -190,48 +192,29 @@ namespace std {
190
  pair<iterator, iterator> equal_range(const K& x);
191
  template<class K>
192
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
193
  };
194
 
195
- template<class InputIterator, class Compare = less<iter_key_t<InputIterator>>,
196
- class Allocator = allocator<iter_to_alloc_t<InputIterator>>>
197
  map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator())
198
- -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>;
199
 
200
  template<class Key, class T, class Compare = less<Key>,
201
  class Allocator = allocator<pair<const Key, T>>>
202
- map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator())
203
  -> map<Key, T, Compare, Allocator>;
204
 
205
  template<class InputIterator, class Allocator>
206
  map(InputIterator, InputIterator, Allocator)
207
- -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>,
208
- less<iter_key_t<InputIterator>>, Allocator>;
209
 
210
  template<class Key, class T, class Allocator>
211
- map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>;
212
 
213
- template <class Key, class T, class Compare, class Allocator>
214
- bool operator==(const map<Key, T, Compare, Allocator>& x,
215
- const map<Key, T, Compare, Allocator>& y);
216
- template <class Key, class T, class Compare, class Allocator>
217
- bool operator< (const map<Key, T, Compare, Allocator>& x,
218
- const map<Key, T, Compare, Allocator>& y);
219
- template <class Key, class T, class Compare, class Allocator>
220
- bool operator!=(const map<Key, T, Compare, Allocator>& x,
221
- const map<Key, T, Compare, Allocator>& y);
222
- template <class Key, class T, class Compare, class Allocator>
223
- bool operator> (const map<Key, T, Compare, Allocator>& x,
224
- const map<Key, T, Compare, Allocator>& y);
225
- template <class Key, class T, class Compare, class Allocator>
226
- bool operator>=(const map<Key, T, Compare, Allocator>& x,
227
- const map<Key, T, Compare, Allocator>& y);
228
- template <class Key, class T, class Compare, class Allocator>
229
- bool operator<=(const map<Key, T, Compare, Allocator>& x,
230
- const map<Key, T, Compare, Allocator>& y);
231
-
232
- // [map.special], specialized algorithms
233
  template<class Key, class T, class Compare, class Allocator>
234
  void swap(map<Key, T, Compare, Allocator>& x,
235
  map<Key, T, Compare, Allocator>& y)
236
  noexcept(noexcept(x.swap(y)));
237
  }
 
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>>>
23
  class map {
24
  public:
25
+ // types
26
  using key_type = Key;
27
  using mapped_type = T;
28
  using value_type = pair<const Key, T>;
29
  using key_compare = Compare;
30
  using allocator_type = Allocator;
 
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;
42
+ using insert_return_type = insert-return-type<iterator, node_type>;
43
 
44
  class value_compare {
45
  friend class map;
46
  protected:
47
  Compare comp;
 
77
  noexcept(allocator_traits<Allocator>::is_always_equal::value &&
78
  is_nothrow_move_assignable_v<Compare>);
79
  map& operator=(initializer_list<value_type>);
80
  allocator_type get_allocator() const noexcept;
81
 
82
+ // iterators
83
  iterator begin() noexcept;
84
  const_iterator begin() const noexcept;
85
  iterator end() noexcept;
86
  const_iterator end() const noexcept;
87
 
 
93
  const_iterator cbegin() const noexcept;
94
  const_iterator cend() const noexcept;
95
  const_reverse_iterator crbegin() const noexcept;
96
  const_reverse_iterator crend() const noexcept;
97
 
98
+ // capacity
99
+ [[nodiscard]] bool empty() const noexcept;
100
  size_type size() const noexcept;
101
  size_type max_size() const noexcept;
102
 
103
  // [map.access], element access
104
+ mapped_type& operator[](const key_type& x);
105
+ mapped_type& operator[](key_type&& x);
106
+ mapped_type& at(const key_type& x);
107
+ const mapped_type& at(const key_type& x) const;
108
 
109
  // [map.modifiers], modifiers
110
  template<class... Args> pair<iterator, bool> emplace(Args&&... args);
111
  template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args);
112
  pair<iterator, bool> insert(const value_type& x);
 
158
  template<class C2>
159
  void merge(multimap<Key, T, C2, Allocator>& source);
160
  template<class C2>
161
  void merge(multimap<Key, T, C2, Allocator>&& source);
162
 
163
+ // observers
164
  key_compare key_comp() const;
165
  value_compare value_comp() const;
166
 
167
+ // map operations
168
  iterator find(const key_type& x);
169
  const_iterator find(const key_type& x) const;
170
  template<class K> iterator find(const K& x);
171
  template<class K> const_iterator find(const K& x) const;
172
 
173
  size_type count(const key_type& x) const;
174
  template<class K> size_type count(const K& x) const;
175
 
176
+ bool contains(const key_type& x) const;
177
+ template<class K> bool contains(const K& x) const;
178
+
179
  iterator lower_bound(const key_type& x);
180
  const_iterator lower_bound(const key_type& x) const;
181
  template<class K> iterator lower_bound(const K& x);
182
  template<class K> const_iterator lower_bound(const K& x) const;
183
 
 
192
  pair<iterator, iterator> equal_range(const K& x);
193
  template<class K>
194
  pair<const_iterator, const_iterator> equal_range(const K& x) const;
195
  };
196
 
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
  }