From Jason Turner

[flat.map.defn]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2ulq410n/{from.md → to.md} +165 -151
tmp/tmp2ulq410n/{from.md → to.md} RENAMED
@@ -23,245 +23,259 @@ namespace std {
23
  using mapped_container_type = MappedContainer;
24
 
25
  class value_compare {
26
  private:
27
  key_compare comp; // exposition only
28
- value_compare(key_compare c) : comp(c) { } // exposition only
29
 
30
  public:
31
- bool operator()(const_reference x, const_reference y) const {
32
  return comp(x.first, y.first);
33
  }
34
  };
35
 
36
  struct containers {
37
  key_container_type keys;
38
  mapped_container_type values;
39
  };
40
 
41
- // [flat.map.cons], construct/copy/destroy
42
- flat_map() : flat_map(key_compare()) { }
43
 
44
- flat_map(key_container_type key_cont, mapped_container_type mapped_cont,
45
- const key_compare& comp = key_compare());
46
- template<class Allocator>
47
- flat_map(const key_container_type& key_cont, const mapped_container_type& mapped_cont,
48
- const Allocator& a);
49
- template<class Allocator>
50
- flat_map(const key_container_type& key_cont, const mapped_container_type& mapped_cont,
51
- const key_compare& comp, const Allocator& a);
52
-
53
- flat_map(sorted_unique_t, key_container_type key_cont, mapped_container_type mapped_cont,
54
- const key_compare& comp = key_compare());
55
- template<class Allocator>
56
- flat_map(sorted_unique_t, const key_container_type& key_cont,
57
- const mapped_container_type& mapped_cont, const Allocator& a);
58
- template<class Allocator>
59
- flat_map(sorted_unique_t, const key_container_type& key_cont,
60
- const mapped_container_type& mapped_cont,
61
- const key_compare& comp, const Allocator& a);
62
-
63
- explicit flat_map(const key_compare& comp)
64
  : c(), compare(comp) { }
65
- template<class Allocator>
66
- flat_map(const key_compare& comp, const Allocator& a);
67
- template<class Allocator>
68
- explicit flat_map(const Allocator& a);
 
 
 
69
 
70
  template<class InputIterator>
71
- flat_map(InputIterator first, InputIterator last, const key_compare& comp = key_compare())
 
72
  : c(), compare(comp) { insert(first, last); }
73
- template<class InputIterator, class Allocator>
74
- flat_map(InputIterator first, InputIterator last,
75
- const key_compare& comp, const Allocator& a);
76
- template<class InputIterator, class Allocator>
77
- flat_map(InputIterator first, InputIterator last, const Allocator& a);
78
 
79
  template<container-compatible-range<value_type> R>
80
- flat_map(from_range_t fr, R&& rg)
81
- : flat_map(fr, std::forward<R>(rg), key_compare()) { }
82
- template<container-compatible-range<value_type> R, class Allocator>
83
- flat_map(from_range_t, R&& rg, const Allocator& a);
84
  template<container-compatible-range<value_type> R>
85
- flat_map(from_range_t, R&& rg, const key_compare& comp)
86
  : flat_map(comp) { insert_range(std::forward<R>(rg)); }
87
- template<container-compatible-range<value_type> R, class Allocator>
88
- flat_map(from_range_t, R&& rg, const key_compare& comp, const Allocator& a);
89
 
90
- template<class InputIterator>
91
- flat_map(sorted_unique_t s, InputIterator first, InputIterator last,
92
- const key_compare& comp = key_compare())
93
- : c(), compare(comp) { insert(s, first, last); }
94
- template<class InputIterator, class Allocator>
95
- flat_map(sorted_unique_t, InputIterator first, InputIterator last,
96
- const key_compare& comp, const Allocator& a);
97
- template<class InputIterator, class Allocator>
98
- flat_map(sorted_unique_t, InputIterator first, InputIterator last, const Allocator& a);
99
-
100
- flat_map(initializer_list<value_type> il, const key_compare& comp = key_compare())
101
  : flat_map(il.begin(), il.end(), comp) { }
102
- template<class Allocator>
103
- flat_map(initializer_list<value_type> il, const key_compare& comp, const Allocator& a);
104
- template<class Allocator>
105
- flat_map(initializer_list<value_type> il, const Allocator& a);
106
 
107
- flat_map(sorted_unique_t s, initializer_list<value_type> il,
108
  const key_compare& comp = key_compare())
109
- : flat_map(s, il.begin(), il.end(), comp) { }
110
- template<class Allocator>
111
- flat_map(sorted_unique_t, initializer_list<value_type> il,
112
- const key_compare& comp, const Allocator& a);
113
- template<class Allocator>
114
- flat_map(sorted_unique_t, initializer_list<value_type> il, const Allocator& a);
115
 
116
- flat_map& operator=(initializer_list<value_type> il);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  // iterators
119
- iterator begin() noexcept;
120
- const_iterator begin() const noexcept;
121
- iterator end() noexcept;
122
- const_iterator end() const noexcept;
123
 
124
- reverse_iterator rbegin() noexcept;
125
- const_reverse_iterator rbegin() const noexcept;
126
- reverse_iterator rend() noexcept;
127
- const_reverse_iterator rend() const noexcept;
128
 
129
- const_iterator cbegin() const noexcept;
130
- const_iterator cend() const noexcept;
131
- const_reverse_iterator crbegin() const noexcept;
132
- const_reverse_iterator crend() const noexcept;
133
 
134
  // [flat.map.capacity], capacity
135
- [[nodiscard]] bool empty() const noexcept;
136
- size_type size() const noexcept;
137
- size_type max_size() const noexcept;
138
 
139
  // [flat.map.access], element access
140
- mapped_type& operator[](const key_type& x);
141
- mapped_type& operator[](key_type&& x);
142
- template<class K> mapped_type& operator[](K&& x);
143
- mapped_type& at(const key_type& x);
144
- const mapped_type& at(const key_type& x) const;
145
- template<class K> mapped_type& at(const K& x);
146
- template<class K> const mapped_type& at(const K& x) const;
147
 
148
  // [flat.map.modifiers], modifiers
149
- template<class... Args> pair<iterator, bool> emplace(Args&&... args);
150
  template<class... Args>
151
- iterator emplace_hint(const_iterator position, Args&&... args);
152
 
153
- pair<iterator, bool> insert(const value_type& x)
154
  { return emplace(x); }
155
- pair<iterator, bool> insert(value_type&& x)
156
  { return emplace(std::move(x)); }
157
- iterator insert(const_iterator position, const value_type& x)
158
  { return emplace_hint(position, x); }
159
- iterator insert(const_iterator position, value_type&& x)
160
  { return emplace_hint(position, std::move(x)); }
161
 
162
- template<class P> pair<iterator, bool> insert(P&& x);
163
  template<class P>
164
- iterator insert(const_iterator position, P&&);
165
  template<class InputIterator>
166
- void insert(InputIterator first, InputIterator last);
167
  template<class InputIterator>
168
- void insert(sorted_unique_t, InputIterator first, InputIterator last);
169
  template<container-compatible-range<value_type> R>
170
- void insert_range(R&& rg);
171
 
172
- void insert(initializer_list<value_type> il)
173
  { insert(il.begin(), il.end()); }
174
- void insert(sorted_unique_t s, initializer_list<value_type> il)
175
- { insert(s, il.begin(), il.end()); }
176
 
177
- containers extract() &&;
178
- void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont);
179
 
180
  template<class... Args>
181
- pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
182
  template<class... Args>
183
- pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
184
  template<class K, class... Args>
185
- pair<iterator, bool> try_emplace(K&& k, Args&&... args);
186
  template<class... Args>
187
- iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
188
  template<class... Args>
189
- iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
190
  template<class K, class... Args>
191
- iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
192
  template<class M>
193
- pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
194
  template<class M>
195
- pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
196
  template<class K, class M>
197
- pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
198
  template<class M>
199
- iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
200
  template<class M>
201
- iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
202
  template<class K, class M>
203
- iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
204
 
205
- iterator erase(iterator position);
206
- iterator erase(const_iterator position);
207
- size_type erase(const key_type& x);
208
- template<class K> size_type erase(K&& x);
209
- iterator erase(const_iterator first, const_iterator last);
210
 
211
- void swap(flat_map& y) noexcept;
212
- void clear() noexcept;
213
 
214
  // observers
215
- key_compare key_comp() const;
216
- value_compare value_comp() const;
217
 
218
- const key_container_type& keys() const noexcept { return c.keys; }
219
- const mapped_container_type& values() const noexcept { return c.values; }
220
 
221
  // map operations
222
- iterator find(const key_type& x);
223
- const_iterator find(const key_type& x) const;
224
- template<class K> iterator find(const K& x);
225
- template<class K> const_iterator find(const K& x) const;
226
 
227
- size_type count(const key_type& x) const;
228
- template<class K> size_type count(const K& x) const;
229
 
230
- bool contains(const key_type& x) const;
231
- template<class K> bool contains(const K& x) const;
232
 
233
- iterator lower_bound(const key_type& x);
234
- const_iterator lower_bound(const key_type& x) const;
235
- template<class K> iterator lower_bound(const K& x);
236
- template<class K> const_iterator lower_bound(const K& x) const;
237
 
238
- iterator upper_bound(const key_type& x);
239
- const_iterator upper_bound(const key_type& x) const;
240
- template<class K> iterator upper_bound(const K& x);
241
- template<class K> const_iterator upper_bound(const K& x) const;
242
 
243
- pair<iterator, iterator> equal_range(const key_type& x);
244
- pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
245
- template<class K> pair<iterator, iterator> equal_range(const K& x);
246
- template<class K> pair<const_iterator, const_iterator> equal_range(const K& x) const;
 
247
 
248
- friend bool operator==(const flat_map& x, const flat_map& y);
249
 
250
- friend synth-three-way-result<value_type>
251
  operator<=>(const flat_map& x, const flat_map& y);
252
 
253
- friend void swap(flat_map& x, flat_map& y) noexcept
254
  { x.swap(y); }
255
 
256
  private:
257
  containers c; // exposition only
258
  key_compare compare; // exposition only
259
 
260
- struct key_equiv { // exposition only
261
- key_equiv(key_compare c) : comp(c) { }
262
- bool operator()(const_reference x, const_reference y) const {
263
  return !comp(x.first, y.first) && !comp(y.first, x.first);
264
  }
265
  key_compare comp;
266
  };
267
  };
 
23
  using mapped_container_type = MappedContainer;
24
 
25
  class value_compare {
26
  private:
27
  key_compare comp; // exposition only
28
+ constexpr value_compare(key_compare c) : comp(c) { } // exposition only
29
 
30
  public:
31
+ constexpr bool operator()(const_reference x, const_reference y) const {
32
  return comp(x.first, y.first);
33
  }
34
  };
35
 
36
  struct containers {
37
  key_container_type keys;
38
  mapped_container_type values;
39
  };
40
 
41
+ // [flat.map.cons], constructors
42
+ constexpr flat_map() : flat_map(key_compare()) { }
43
 
44
+ constexpr explicit flat_map(const key_compare& comp)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  : c(), compare(comp) { }
46
+
47
+ constexpr flat_map(key_container_type key_cont, mapped_container_type mapped_cont,
48
+ const key_compare& comp = key_compare());
49
+
50
+ constexpr flat_map(sorted_unique_t, key_container_type key_cont,
51
+ mapped_container_type mapped_cont,
52
+ const key_compare& comp = key_compare());
53
 
54
  template<class InputIterator>
55
+ constexpr flat_map(InputIterator first, InputIterator last,
56
+ const key_compare& comp = key_compare())
57
  : c(), compare(comp) { insert(first, last); }
58
+
59
+ template<class InputIterator>
60
+ constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last,
61
+ const key_compare& comp = key_compare())
62
+ : c(), compare(comp) { insert(sorted_unique, first, last); }
63
 
64
  template<container-compatible-range<value_type> R>
65
+ constexpr flat_map(from_range_t, R&& rg)
66
+ : flat_map(from_range, std::forward<R>(rg), key_compare()) { }
 
 
67
  template<container-compatible-range<value_type> R>
68
+ constexpr flat_map(from_range_t, R&& rg, const key_compare& comp)
69
  : flat_map(comp) { insert_range(std::forward<R>(rg)); }
 
 
70
 
71
+ constexpr flat_map(initializer_list<value_type> il, const key_compare& comp = key_compare())
 
 
 
 
 
 
 
 
 
 
72
  : flat_map(il.begin(), il.end(), comp) { }
 
 
 
 
73
 
74
+ constexpr flat_map(sorted_unique_t, initializer_list<value_type> il,
75
  const key_compare& comp = key_compare())
76
+ : flat_map(sorted_unique, il.begin(), il.end(), comp) { }
 
 
 
 
 
77
 
78
+ // [flat.map.cons.alloc], constructors with allocators
79
+
80
+ template<class Alloc>
81
+ constexpr explicit flat_map(const Alloc& a);
82
+ template<class Alloc>
83
+ constexpr flat_map(const key_compare& comp, const Alloc& a);
84
+ template<class Alloc>
85
+ constexpr flat_map(const key_container_type& key_cont,
86
+ const mapped_container_type& mapped_cont,
87
+ const Alloc& a);
88
+ template<class Alloc>
89
+ constexpr flat_map(const key_container_type& key_cont,
90
+ const mapped_container_type& mapped_cont,
91
+ const key_compare& comp, const Alloc& a);
92
+ template<class Alloc>
93
+ constexpr flat_map(sorted_unique_t, const key_container_type& key_cont,
94
+ const mapped_container_type& mapped_cont, const Alloc& a);
95
+ template<class Alloc>
96
+ constexpr flat_map(sorted_unique_t, const key_container_type& key_cont,
97
+ const mapped_container_type& mapped_cont, const key_compare& comp,
98
+ const Alloc& a);
99
+ template<class Alloc>
100
+ constexpr flat_map(const flat_map&, const Alloc& a);
101
+ template<class Alloc>
102
+ constexpr flat_map(flat_map&&, const Alloc& a);
103
+ template<class InputIterator, class Alloc>
104
+ constexpr flat_map(InputIterator first, InputIterator last, const Alloc& a);
105
+ template<class InputIterator, class Alloc>
106
+ constexpr flat_map(InputIterator first, InputIterator last,
107
+ const key_compare& comp, const Alloc& a);
108
+ template<class InputIterator, class Alloc>
109
+ constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last,
110
+ const Alloc& a);
111
+ template<class InputIterator, class Alloc>
112
+ constexpr flat_map(sorted_unique_t, InputIterator first, InputIterator last,
113
+ const key_compare& comp, const Alloc& a);
114
+ template<container-compatible-range<value_type> R, class Alloc>
115
+ constexpr flat_map(from_range_t, R&& rg, const Alloc& a);
116
+ template<container-compatible-range<value_type> R, class Alloc>
117
+ constexpr flat_map(from_range_t, R&& rg, const key_compare& comp, const Alloc& a);
118
+ template<class Alloc>
119
+ constexpr flat_map(initializer_list<value_type> il, const Alloc& a);
120
+ template<class Alloc>
121
+ constexpr flat_map(initializer_list<value_type> il, const key_compare& comp,
122
+ const Alloc& a);
123
+ template<class Alloc>
124
+ constexpr flat_map(sorted_unique_t, initializer_list<value_type> il, const Alloc& a);
125
+ template<class Alloc>
126
+ constexpr flat_map(sorted_unique_t, initializer_list<value_type> il,
127
+ const key_compare& comp, const Alloc& a);
128
+
129
+ constexpr flat_map& operator=(initializer_list<value_type>);
130
 
131
  // iterators
132
+ constexpr iterator begin() noexcept;
133
+ constexpr const_iterator begin() const noexcept;
134
+ constexpr iterator end() noexcept;
135
+ constexpr const_iterator end() const noexcept;
136
 
137
+ constexpr reverse_iterator rbegin() noexcept;
138
+ constexpr const_reverse_iterator rbegin() const noexcept;
139
+ constexpr reverse_iterator rend() noexcept;
140
+ constexpr const_reverse_iterator rend() const noexcept;
141
 
142
+ constexpr const_iterator cbegin() const noexcept;
143
+ constexpr const_iterator cend() const noexcept;
144
+ constexpr const_reverse_iterator crbegin() const noexcept;
145
+ constexpr const_reverse_iterator crend() const noexcept;
146
 
147
  // [flat.map.capacity], capacity
148
+ constexpr bool empty() const noexcept;
149
+ constexpr size_type size() const noexcept;
150
+ constexpr size_type max_size() const noexcept;
151
 
152
  // [flat.map.access], element access
153
+ constexpr mapped_type& operator[](const key_type& x);
154
+ constexpr mapped_type& operator[](key_type&& x);
155
+ template<class K> constexpr mapped_type& operator[](K&& x);
156
+ constexpr mapped_type& at(const key_type& x);
157
+ constexpr const mapped_type& at(const key_type& x) const;
158
+ template<class K> constexpr mapped_type& at(const K& x);
159
+ template<class K> constexpr const mapped_type& at(const K& x) const;
160
 
161
  // [flat.map.modifiers], modifiers
162
+ template<class... Args> constexpr pair<iterator, bool> emplace(Args&&... args);
163
  template<class... Args>
164
+ constexpr iterator emplace_hint(const_iterator position, Args&&... args);
165
 
166
+ constexpr pair<iterator, bool> insert(const value_type& x)
167
  { return emplace(x); }
168
+ constexpr pair<iterator, bool> insert(value_type&& x)
169
  { return emplace(std::move(x)); }
170
+ constexpr iterator insert(const_iterator position, const value_type& x)
171
  { return emplace_hint(position, x); }
172
+ constexpr iterator insert(const_iterator position, value_type&& x)
173
  { return emplace_hint(position, std::move(x)); }
174
 
175
+ template<class P> constexpr pair<iterator, bool> insert(P&& x);
176
  template<class P>
177
+ constexpr iterator insert(const_iterator position, P&&);
178
  template<class InputIterator>
179
+ constexpr void insert(InputIterator first, InputIterator last);
180
  template<class InputIterator>
181
+ constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
182
  template<container-compatible-range<value_type> R>
183
+ constexpr void insert_range(R&& rg);
184
 
185
+ constexpr void insert(initializer_list<value_type> il)
186
  { insert(il.begin(), il.end()); }
187
+ constexpr void insert(sorted_unique_t, initializer_list<value_type> il)
188
+ { insert(sorted_unique, il.begin(), il.end()); }
189
 
190
+ constexpr containers extract() &&;
191
+ constexpr void replace(key_container_type&& key_cont, mapped_container_type&& mapped_cont);
192
 
193
  template<class... Args>
194
+ constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
195
  template<class... Args>
196
+ constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args);
197
  template<class K, class... Args>
198
+ constexpr pair<iterator, bool> try_emplace(K&& k, Args&&... args);
199
  template<class... Args>
200
+ constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args);
201
  template<class... Args>
202
+ constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args);
203
  template<class K, class... Args>
204
+ constexpr iterator try_emplace(const_iterator hint, K&& k, Args&&... args);
205
  template<class M>
206
+ constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj);
207
  template<class M>
208
+ constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj);
209
  template<class K, class M>
210
+ constexpr pair<iterator, bool> insert_or_assign(K&& k, M&& obj);
211
  template<class M>
212
+ constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj);
213
  template<class M>
214
+ constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj);
215
  template<class K, class M>
216
+ constexpr iterator insert_or_assign(const_iterator hint, K&& k, M&& obj);
217
 
218
+ constexpr iterator erase(iterator position);
219
+ constexpr iterator erase(const_iterator position);
220
+ constexpr size_type erase(const key_type& x);
221
+ template<class K> constexpr size_type erase(K&& x);
222
+ constexpr iterator erase(const_iterator first, const_iterator last);
223
 
224
+ constexpr void swap(flat_map& y) noexcept;
225
+ constexpr void clear() noexcept;
226
 
227
  // observers
228
+ constexpr key_compare key_comp() const;
229
+ constexpr value_compare value_comp() const;
230
 
231
+ constexpr const key_container_type& keys() const noexcept { return c.keys; }
232
+ constexpr const mapped_container_type& values() const noexcept { return c.values; }
233
 
234
  // map operations
235
+ constexpr iterator find(const key_type& x);
236
+ constexpr const_iterator find(const key_type& x) const;
237
+ template<class K> constexpr iterator find(const K& x);
238
+ template<class K> constexpr const_iterator find(const K& x) const;
239
 
240
+ constexpr size_type count(const key_type& x) const;
241
+ template<class K> constexpr size_type count(const K& x) const;
242
 
243
+ constexpr bool contains(const key_type& x) const;
244
+ template<class K> constexpr bool contains(const K& x) const;
245
 
246
+ constexpr iterator lower_bound(const key_type& x);
247
+ constexpr const_iterator lower_bound(const key_type& x) const;
248
+ template<class K> constexpr iterator lower_bound(const K& x);
249
+ template<class K> constexpr const_iterator lower_bound(const K& x) const;
250
 
251
+ constexpr iterator upper_bound(const key_type& x);
252
+ constexpr const_iterator upper_bound(const key_type& x) const;
253
+ template<class K> constexpr iterator upper_bound(const K& x);
254
+ template<class K> constexpr const_iterator upper_bound(const K& x) const;
255
 
256
+ constexpr pair<iterator, iterator> equal_range(const key_type& x);
257
+ constexpr pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
258
+ template<class K> constexpr pair<iterator, iterator> equal_range(const K& x);
259
+ template<class K>
260
+ constexpr pair<const_iterator, const_iterator> equal_range(const K& x) const;
261
 
262
+ friend constexpr bool operator==(const flat_map& x, const flat_map& y);
263
 
264
+ friend constexpr synth-three-way-result<value_type>
265
  operator<=>(const flat_map& x, const flat_map& y);
266
 
267
+ friend constexpr void swap(flat_map& x, flat_map& y) noexcept
268
  { x.swap(y); }
269
 
270
  private:
271
  containers c; // exposition only
272
  key_compare compare; // exposition only
273
 
274
+ struct key-equiv { // exposition only
275
+ constexpr key-equiv(key_compare c) : comp(c) { }
276
+ constexpr bool operator()(const_reference x, const_reference y) const {
277
  return !comp(x.first, y.first) && !comp(y.first, x.first);
278
  }
279
  key_compare comp;
280
  };
281
  };