]>
Commit | Line | Data |
---|---|---|
285b36d6 BK |
1 | // Debugging multimap implementation -*- C++ -*- |
2 | ||
85ec4feb | 3 | // Copyright (C) 2003-2018 Free Software Foundation, Inc. |
285b36d6 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
285b36d6 BK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
285b36d6 | 24 | |
78a53887 BK |
25 | /** @file debug/multimap.h |
26 | * This file is a GNU debug extension to the Standard C++ Library. | |
27 | */ | |
28 | ||
285b36d6 BK |
29 | #ifndef _GLIBCXX_DEBUG_MULTIMAP_H |
30 | #define _GLIBCXX_DEBUG_MULTIMAP_H 1 | |
31 | ||
32 | #include <debug/safe_sequence.h> | |
15ee1a77 | 33 | #include <debug/safe_container.h> |
285b36d6 BK |
34 | #include <debug/safe_iterator.h> |
35 | #include <utility> | |
36 | ||
12ffa228 | 37 | namespace std _GLIBCXX_VISIBILITY(default) |
3cbc7af0 | 38 | { |
45f388bb | 39 | namespace __debug |
285b36d6 | 40 | { |
1ceb9e06 | 41 | /// Class std::multimap with safety/checking/debug instrumentation. |
285b36d6 BK |
42 | template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>, |
43 | typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > > | |
526da49c | 44 | class multimap |
15ee1a77 FD |
45 | : public __gnu_debug::_Safe_container< |
46 | multimap<_Key, _Tp, _Compare, _Allocator>, _Allocator, | |
47 | __gnu_debug::_Safe_node_sequence>, | |
48 | public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> | |
285b36d6 | 49 | { |
15ee1a77 FD |
50 | typedef _GLIBCXX_STD_C::multimap< |
51 | _Key, _Tp, _Compare, _Allocator> _Base; | |
52 | typedef __gnu_debug::_Safe_container< | |
53 | multimap, _Allocator, __gnu_debug::_Safe_node_sequence> _Safe; | |
526da49c | 54 | |
15ee1a77 FD |
55 | typedef typename _Base::const_iterator _Base_const_iterator; |
56 | typedef typename _Base::iterator _Base_iterator; | |
afe96d41 | 57 | typedef __gnu_debug::_Equal_to<_Base_const_iterator> _Equal; |
51835a80 | 58 | |
285b36d6 BK |
59 | public: |
60 | // types: | |
15ee1a77 FD |
61 | typedef _Key key_type; |
62 | typedef _Tp mapped_type; | |
63 | typedef std::pair<const _Key, _Tp> value_type; | |
64 | typedef _Compare key_compare; | |
65 | typedef _Allocator allocator_type; | |
66 | typedef typename _Base::reference reference; | |
67 | typedef typename _Base::const_reference const_reference; | |
526da49c | 68 | |
afe96d41 | 69 | typedef __gnu_debug::_Safe_iterator<_Base_iterator, multimap> |
15ee1a77 | 70 | iterator; |
afe96d41 | 71 | typedef __gnu_debug::_Safe_iterator<_Base_const_iterator, |
15ee1a77 | 72 | multimap> const_iterator; |
285b36d6 | 73 | |
15ee1a77 FD |
74 | typedef typename _Base::size_type size_type; |
75 | typedef typename _Base::difference_type difference_type; | |
76 | typedef typename _Base::pointer pointer; | |
77 | typedef typename _Base::const_pointer const_pointer; | |
78 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
79 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
526da49c | 80 | |
285b36d6 | 81 | // 23.3.1.1 construct/copy/destroy: |
c3cdd71f | 82 | |
15ee1a77 | 83 | #if __cplusplus < 201103L |
c3cdd71f JW |
84 | multimap() : _Base() { } |
85 | ||
ed540c0a | 86 | multimap(const multimap& __x) |
4c2d93db | 87 | : _Base(__x) { } |
285b36d6 | 88 | |
15ee1a77 FD |
89 | ~multimap() { } |
90 | #else | |
91 | multimap() = default; | |
92 | multimap(const multimap&) = default; | |
93 | multimap(multimap&&) = default; | |
988499f4 JM |
94 | |
95 | multimap(initializer_list<value_type> __l, | |
96 | const _Compare& __c = _Compare(), | |
97 | const allocator_type& __a = allocator_type()) | |
4c2d93db | 98 | : _Base(__l, __c, __a) { } |
51835a80 FD |
99 | |
100 | explicit | |
101 | multimap(const allocator_type& __a) | |
102 | : _Base(__a) { } | |
103 | ||
104 | multimap(const multimap& __m, const allocator_type& __a) | |
105 | : _Base(__m, __a) { } | |
106 | ||
107 | multimap(multimap&& __m, const allocator_type& __a) | |
8b0cd47a | 108 | noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) ) |
15ee1a77 FD |
109 | : _Safe(std::move(__m._M_safe()), __a), |
110 | _Base(std::move(__m._M_base()), __a) { } | |
51835a80 FD |
111 | |
112 | multimap(initializer_list<value_type> __l, const allocator_type& __a) | |
15ee1a77 | 113 | : _Base(__l, __a) { } |
51835a80 FD |
114 | |
115 | template<typename _InputIterator> | |
15ee1a77 | 116 | multimap(_InputIterator __first, _InputIterator __last, |
51835a80 | 117 | const allocator_type& __a) |
90aabc7e FD |
118 | : _Base(__gnu_debug::__base( |
119 | __glibcxx_check_valid_constructor_range(__first, __last)), | |
15ee1a77 FD |
120 | __gnu_debug::__base(__last), __a) { } |
121 | ||
122 | ~multimap() = default; | |
ed540c0a | 123 | #endif |
285b36d6 | 124 | |
15ee1a77 FD |
125 | explicit multimap(const _Compare& __comp, |
126 | const _Allocator& __a = _Allocator()) | |
127 | : _Base(__comp, __a) { } | |
128 | ||
129 | template<typename _InputIterator> | |
130 | multimap(_InputIterator __first, _InputIterator __last, | |
131 | const _Compare& __comp = _Compare(), | |
132 | const _Allocator& __a = _Allocator()) | |
90aabc7e FD |
133 | : _Base(__gnu_debug::__base( |
134 | __glibcxx_check_valid_constructor_range(__first, __last)), | |
15ee1a77 FD |
135 | __gnu_debug::__base(__last), |
136 | __comp, __a) { } | |
137 | ||
138 | multimap(const _Base& __x) | |
139 | : _Base(__x) { } | |
285b36d6 | 140 | |
15ee1a77 | 141 | #if __cplusplus < 201103L |
ed540c0a CJ |
142 | multimap& |
143 | operator=(const multimap& __x) | |
285b36d6 | 144 | { |
15ee1a77 | 145 | this->_M_safe() = __x; |
51835a80 | 146 | _M_base() = __x; |
285b36d6 BK |
147 | return *this; |
148 | } | |
15ee1a77 FD |
149 | #else |
150 | multimap& | |
151 | operator=(const multimap&) = default; | |
285b36d6 | 152 | |
ed540c0a | 153 | multimap& |
15ee1a77 | 154 | operator=(multimap&&) = default; |
988499f4 JM |
155 | |
156 | multimap& | |
157 | operator=(initializer_list<value_type> __l) | |
158 | { | |
51835a80 FD |
159 | _M_base() = __l; |
160 | this->_M_invalidate_all(); | |
988499f4 JM |
161 | return *this; |
162 | } | |
ed540c0a CJ |
163 | #endif |
164 | ||
285b36d6 BK |
165 | using _Base::get_allocator; |
166 | ||
167 | // iterators: | |
526da49c | 168 | iterator |
d3677132 | 169 | begin() _GLIBCXX_NOEXCEPT |
285b36d6 BK |
170 | { return iterator(_Base::begin(), this); } |
171 | ||
526da49c | 172 | const_iterator |
d3677132 | 173 | begin() const _GLIBCXX_NOEXCEPT |
285b36d6 BK |
174 | { return const_iterator(_Base::begin(), this); } |
175 | ||
526da49c | 176 | iterator |
d3677132 | 177 | end() _GLIBCXX_NOEXCEPT |
285b36d6 BK |
178 | { return iterator(_Base::end(), this); } |
179 | ||
526da49c | 180 | const_iterator |
d3677132 | 181 | end() const _GLIBCXX_NOEXCEPT |
285b36d6 BK |
182 | { return const_iterator(_Base::end(), this); } |
183 | ||
526da49c | 184 | reverse_iterator |
d3677132 | 185 | rbegin() _GLIBCXX_NOEXCEPT |
285b36d6 BK |
186 | { return reverse_iterator(end()); } |
187 | ||
526da49c | 188 | const_reverse_iterator |
d3677132 | 189 | rbegin() const _GLIBCXX_NOEXCEPT |
285b36d6 BK |
190 | { return const_reverse_iterator(end()); } |
191 | ||
526da49c | 192 | reverse_iterator |
d3677132 | 193 | rend() _GLIBCXX_NOEXCEPT |
285b36d6 BK |
194 | { return reverse_iterator(begin()); } |
195 | ||
526da49c | 196 | const_reverse_iterator |
d3677132 | 197 | rend() const _GLIBCXX_NOEXCEPT |
285b36d6 BK |
198 | { return const_reverse_iterator(begin()); } |
199 | ||
734f5023 | 200 | #if __cplusplus >= 201103L |
0cd50f89 | 201 | const_iterator |
d3677132 | 202 | cbegin() const noexcept |
0cd50f89 PC |
203 | { return const_iterator(_Base::begin(), this); } |
204 | ||
205 | const_iterator | |
d3677132 | 206 | cend() const noexcept |
0cd50f89 PC |
207 | { return const_iterator(_Base::end(), this); } |
208 | ||
209 | const_reverse_iterator | |
d3677132 | 210 | crbegin() const noexcept |
0cd50f89 PC |
211 | { return const_reverse_iterator(end()); } |
212 | ||
213 | const_reverse_iterator | |
d3677132 | 214 | crend() const noexcept |
0cd50f89 PC |
215 | { return const_reverse_iterator(begin()); } |
216 | #endif | |
217 | ||
285b36d6 BK |
218 | // capacity: |
219 | using _Base::empty; | |
220 | using _Base::size; | |
221 | using _Base::max_size; | |
222 | ||
223 | // modifiers: | |
734f5023 | 224 | #if __cplusplus >= 201103L |
55826ab6 FD |
225 | template<typename... _Args> |
226 | iterator | |
227 | emplace(_Args&&... __args) | |
228 | { | |
229 | return iterator(_Base::emplace(std::forward<_Args>(__args)...), this); | |
230 | } | |
231 | ||
232 | template<typename... _Args> | |
233 | iterator | |
234 | emplace_hint(const_iterator __pos, _Args&&... __args) | |
235 | { | |
236 | __glibcxx_check_insert(__pos); | |
237 | return iterator(_Base::emplace_hint(__pos.base(), | |
238 | std::forward<_Args>(__args)...), | |
239 | this); | |
240 | } | |
241 | #endif | |
15ee1a77 | 242 | |
526da49c | 243 | iterator |
285b36d6 BK |
244 | insert(const value_type& __x) |
245 | { return iterator(_Base::insert(__x), this); } | |
246 | ||
734f5023 | 247 | #if __cplusplus >= 201103L |
1679da15 FD |
248 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
249 | // 2354. Unnecessary copying when inserting into maps with braced-init | |
250 | iterator | |
251 | insert(value_type&& __x) | |
252 | { return { _Base::insert(std::move(__x)), this }; } | |
253 | ||
e6a05448 | 254 | template<typename _Pair, typename = typename |
57cee56a PC |
255 | std::enable_if<std::is_constructible<value_type, |
256 | _Pair&&>::value>::type> | |
15ee1a77 FD |
257 | iterator |
258 | insert(_Pair&& __x) | |
259 | { return iterator(_Base::insert(std::forward<_Pair>(__x)), this); } | |
e6a05448 PC |
260 | #endif |
261 | ||
734f5023 | 262 | #if __cplusplus >= 201103L |
988499f4 JM |
263 | void |
264 | insert(std::initializer_list<value_type> __list) | |
265 | { _Base::insert(__list); } | |
266 | #endif | |
267 | ||
526da49c | 268 | iterator |
734f5023 | 269 | #if __cplusplus >= 201103L |
6b6d5d09 PC |
270 | insert(const_iterator __position, const value_type& __x) |
271 | #else | |
afe96d41 | 272 | insert(iterator __position, const value_type& __x) |
6b6d5d09 | 273 | #endif |
285b36d6 BK |
274 | { |
275 | __glibcxx_check_insert(__position); | |
276 | return iterator(_Base::insert(__position.base(), __x), this); | |
277 | } | |
278 | ||
734f5023 | 279 | #if __cplusplus >= 201103L |
1679da15 FD |
280 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
281 | // 2354. Unnecessary copying when inserting into maps with braced-init | |
282 | iterator | |
283 | insert(const_iterator __position, value_type&& __x) | |
284 | { | |
285 | __glibcxx_check_insert(__position); | |
286 | return { _Base::insert(__position.base(), std::move(__x)), this }; | |
287 | } | |
288 | ||
e6a05448 | 289 | template<typename _Pair, typename = typename |
57cee56a PC |
290 | std::enable_if<std::is_constructible<value_type, |
291 | _Pair&&>::value>::type> | |
15ee1a77 FD |
292 | iterator |
293 | insert(const_iterator __position, _Pair&& __x) | |
294 | { | |
e6a05448 PC |
295 | __glibcxx_check_insert(__position); |
296 | return iterator(_Base::insert(__position.base(), | |
297 | std::forward<_Pair>(__x)), this); | |
298 | } | |
299 | #endif | |
300 | ||
285b36d6 | 301 | template<typename _InputIterator> |
15ee1a77 FD |
302 | void |
303 | insert(_InputIterator __first, _InputIterator __last) | |
304 | { | |
24167c42 FD |
305 | typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; |
306 | __glibcxx_check_valid_range2(__first, __last, __dist); | |
307 | ||
308 | if (__dist.second >= __gnu_debug::__dp_sign) | |
309 | _Base::insert(__gnu_debug::__unsafe(__first), | |
310 | __gnu_debug::__unsafe(__last)); | |
311 | else | |
312 | _Base::insert(__first, __last); | |
285b36d6 BK |
313 | } |
314 | ||
2dbe56bd JW |
315 | #if __cplusplus > 201402L |
316 | using node_type = typename _Base::node_type; | |
317 | ||
318 | node_type | |
319 | extract(const_iterator __position) | |
320 | { | |
321 | __glibcxx_check_erase(__position); | |
322 | this->_M_invalidate_if(_Equal(__position.base())); | |
323 | return _Base::extract(__position.base()); | |
324 | } | |
325 | ||
326 | node_type | |
327 | extract(const key_type& __key) | |
328 | { | |
329 | const auto __position = find(__key); | |
330 | if (__position != end()) | |
331 | return extract(__position); | |
332 | return {}; | |
333 | } | |
334 | ||
335 | iterator | |
336 | insert(node_type&& __nh) | |
337 | { return iterator(_Base::insert(std::move(__nh)), this); } | |
338 | ||
339 | iterator | |
340 | insert(const_iterator __hint, node_type&& __nh) | |
341 | { | |
342 | __glibcxx_check_insert(__hint); | |
343 | return iterator(_Base::insert(__hint.base(), std::move(__nh)), this); | |
344 | } | |
345 | ||
346 | using _Base::merge; | |
347 | #endif // C++17 | |
348 | ||
734f5023 | 349 | #if __cplusplus >= 201103L |
5ab06c6d | 350 | iterator |
6b6d5d09 | 351 | erase(const_iterator __position) |
5ab06c6d PC |
352 | { |
353 | __glibcxx_check_erase(__position); | |
afe96d41 | 354 | this->_M_invalidate_if(_Equal(__position.base())); |
5ab06c6d PC |
355 | return iterator(_Base::erase(__position.base()), this); |
356 | } | |
6dc88283 PC |
357 | |
358 | iterator | |
359 | erase(iterator __position) | |
360 | { return erase(const_iterator(__position)); } | |
5ab06c6d | 361 | #else |
526da49c | 362 | void |
285b36d6 BK |
363 | erase(iterator __position) |
364 | { | |
365 | __glibcxx_check_erase(__position); | |
afe96d41 | 366 | this->_M_invalidate_if(_Equal(__position.base())); |
285b36d6 BK |
367 | _Base::erase(__position.base()); |
368 | } | |
5ab06c6d | 369 | #endif |
285b36d6 | 370 | |
526da49c | 371 | size_type |
285b36d6 BK |
372 | erase(const key_type& __x) |
373 | { | |
afe96d41 FD |
374 | std::pair<_Base_iterator, _Base_iterator> __victims = |
375 | _Base::equal_range(__x); | |
285b36d6 | 376 | size_type __count = 0; |
afe96d41 FD |
377 | _Base_iterator __victim = __victims.first; |
378 | while (__victim != __victims.second) | |
379 | { | |
380 | this->_M_invalidate_if(_Equal(__victim)); | |
381 | _Base::erase(__victim++); | |
382 | ++__count; | |
383 | } | |
285b36d6 BK |
384 | return __count; |
385 | } | |
386 | ||
734f5023 | 387 | #if __cplusplus >= 201103L |
5ab06c6d | 388 | iterator |
6b6d5d09 | 389 | erase(const_iterator __first, const_iterator __last) |
5ab06c6d PC |
390 | { |
391 | // _GLIBCXX_RESOLVE_LIB_DEFECTS | |
392 | // 151. can't currently clear() empty container | |
393 | __glibcxx_check_erase_range(__first, __last); | |
afe96d41 FD |
394 | for (_Base_const_iterator __victim = __first.base(); |
395 | __victim != __last.base(); ++__victim) | |
396 | { | |
397 | _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), | |
398 | _M_message(__gnu_debug::__msg_valid_range) | |
399 | ._M_iterator(__first, "first") | |
400 | ._M_iterator(__last, "last")); | |
401 | this->_M_invalidate_if(_Equal(__victim)); | |
402 | } | |
403 | return iterator(_Base::erase(__first.base(), __last.base()), this); | |
5ab06c6d PC |
404 | } |
405 | #else | |
526da49c | 406 | void |
285b36d6 BK |
407 | erase(iterator __first, iterator __last) |
408 | { | |
409 | // _GLIBCXX_RESOLVE_LIB_DEFECTS | |
410 | // 151. can't currently clear() empty container | |
411 | __glibcxx_check_erase_range(__first, __last); | |
afe96d41 FD |
412 | for (_Base_iterator __victim = __first.base(); |
413 | __victim != __last.base(); ++__victim) | |
414 | { | |
415 | _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(), | |
416 | _M_message(__gnu_debug::__msg_valid_range) | |
417 | ._M_iterator(__first, "first") | |
418 | ._M_iterator(__last, "last")); | |
419 | this->_M_invalidate_if(_Equal(__victim)); | |
420 | } | |
421 | _Base::erase(__first.base(), __last.base()); | |
285b36d6 | 422 | } |
5ab06c6d | 423 | #endif |
285b36d6 | 424 | |
526da49c | 425 | void |
ed540c0a | 426 | swap(multimap& __x) |
c5d9ec56 | 427 | _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) |
285b36d6 | 428 | { |
15ee1a77 | 429 | _Safe::_M_swap(__x); |
285b36d6 | 430 | _Base::swap(__x); |
285b36d6 BK |
431 | } |
432 | ||
526da49c | 433 | void |
d3677132 | 434 | clear() _GLIBCXX_NOEXCEPT |
afe96d41 FD |
435 | { |
436 | this->_M_invalidate_all(); | |
437 | _Base::clear(); | |
438 | } | |
285b36d6 BK |
439 | |
440 | // observers: | |
441 | using _Base::key_comp; | |
442 | using _Base::value_comp; | |
443 | ||
444 | // 23.3.1.3 multimap operations: | |
526da49c | 445 | iterator |
285b36d6 BK |
446 | find(const key_type& __x) |
447 | { return iterator(_Base::find(__x), this); } | |
448 | ||
d7b35f22 FD |
449 | #if __cplusplus > 201103L |
450 | template<typename _Kt, | |
451 | typename _Req = | |
452 | typename __has_is_transparent<_Compare, _Kt>::type> | |
453 | iterator | |
454 | find(const _Kt& __x) | |
455 | { return { _Base::find(__x), this }; } | |
456 | #endif | |
457 | ||
526da49c | 458 | const_iterator |
285b36d6 BK |
459 | find(const key_type& __x) const |
460 | { return const_iterator(_Base::find(__x), this); } | |
461 | ||
d7b35f22 FD |
462 | #if __cplusplus > 201103L |
463 | template<typename _Kt, | |
464 | typename _Req = | |
465 | typename __has_is_transparent<_Compare, _Kt>::type> | |
466 | const_iterator | |
467 | find(const _Kt& __x) const | |
468 | { return { _Base::find(__x), this }; } | |
469 | #endif | |
470 | ||
285b36d6 BK |
471 | using _Base::count; |
472 | ||
526da49c | 473 | iterator |
285b36d6 BK |
474 | lower_bound(const key_type& __x) |
475 | { return iterator(_Base::lower_bound(__x), this); } | |
476 | ||
d7b35f22 FD |
477 | #if __cplusplus > 201103L |
478 | template<typename _Kt, | |
479 | typename _Req = | |
480 | typename __has_is_transparent<_Compare, _Kt>::type> | |
481 | iterator | |
482 | lower_bound(const _Kt& __x) | |
483 | { return { _Base::lower_bound(__x), this }; } | |
484 | #endif | |
485 | ||
526da49c | 486 | const_iterator |
285b36d6 BK |
487 | lower_bound(const key_type& __x) const |
488 | { return const_iterator(_Base::lower_bound(__x), this); } | |
489 | ||
d7b35f22 FD |
490 | #if __cplusplus > 201103L |
491 | template<typename _Kt, | |
492 | typename _Req = | |
493 | typename __has_is_transparent<_Compare, _Kt>::type> | |
494 | const_iterator | |
495 | lower_bound(const _Kt& __x) const | |
496 | { return { _Base::lower_bound(__x), this }; } | |
497 | #endif | |
498 | ||
526da49c | 499 | iterator |
285b36d6 BK |
500 | upper_bound(const key_type& __x) |
501 | { return iterator(_Base::upper_bound(__x), this); } | |
502 | ||
d7b35f22 FD |
503 | #if __cplusplus > 201103L |
504 | template<typename _Kt, | |
505 | typename _Req = | |
506 | typename __has_is_transparent<_Compare, _Kt>::type> | |
507 | iterator | |
508 | upper_bound(const _Kt& __x) | |
509 | { return { _Base::upper_bound(__x), this }; } | |
510 | #endif | |
511 | ||
526da49c | 512 | const_iterator |
285b36d6 BK |
513 | upper_bound(const key_type& __x) const |
514 | { return const_iterator(_Base::upper_bound(__x), this); } | |
515 | ||
d7b35f22 FD |
516 | #if __cplusplus > 201103L |
517 | template<typename _Kt, | |
518 | typename _Req = | |
519 | typename __has_is_transparent<_Compare, _Kt>::type> | |
520 | const_iterator | |
521 | upper_bound(const _Kt& __x) const | |
522 | { return { _Base::upper_bound(__x), this }; } | |
523 | #endif | |
524 | ||
285b36d6 BK |
525 | std::pair<iterator,iterator> |
526 | equal_range(const key_type& __x) | |
527 | { | |
285b36d6 BK |
528 | std::pair<_Base_iterator, _Base_iterator> __res = |
529 | _Base::equal_range(__x); | |
530 | return std::make_pair(iterator(__res.first, this), | |
531 | iterator(__res.second, this)); | |
532 | } | |
533 | ||
d7b35f22 FD |
534 | #if __cplusplus > 201103L |
535 | template<typename _Kt, | |
536 | typename _Req = | |
537 | typename __has_is_transparent<_Compare, _Kt>::type> | |
538 | std::pair<iterator, iterator> | |
539 | equal_range(const _Kt& __x) | |
540 | { | |
541 | auto __res = _Base::equal_range(__x); | |
542 | return { { __res.first, this }, { __res.second, this } }; | |
543 | } | |
544 | #endif | |
545 | ||
285b36d6 BK |
546 | std::pair<const_iterator,const_iterator> |
547 | equal_range(const key_type& __x) const | |
548 | { | |
285b36d6 | 549 | std::pair<_Base_const_iterator, _Base_const_iterator> __res = |
afe96d41 | 550 | _Base::equal_range(__x); |
285b36d6 BK |
551 | return std::make_pair(const_iterator(__res.first, this), |
552 | const_iterator(__res.second, this)); | |
553 | } | |
554 | ||
d7b35f22 FD |
555 | #if __cplusplus > 201103L |
556 | template<typename _Kt, | |
557 | typename _Req = | |
558 | typename __has_is_transparent<_Compare, _Kt>::type> | |
559 | std::pair<const_iterator, const_iterator> | |
560 | equal_range(const _Kt& __x) const | |
561 | { | |
562 | auto __res = _Base::equal_range(__x); | |
563 | return { { __res.first, this }, { __res.second, this } }; | |
564 | } | |
565 | #endif | |
566 | ||
526da49c | 567 | _Base& |
15ee1a77 | 568 | _M_base() _GLIBCXX_NOEXCEPT { return *this; } |
285b36d6 | 569 | |
526da49c | 570 | const _Base& |
d3677132 | 571 | _M_base() const _GLIBCXX_NOEXCEPT { return *this; } |
285b36d6 BK |
572 | }; |
573 | ||
957f5fea VV |
574 | #if __cpp_deduction_guides >= 201606 |
575 | ||
576 | template<typename _InputIterator, | |
577 | typename _Compare = less<__iter_key_t<_InputIterator>>, | |
578 | typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, | |
579 | typename = _RequireInputIter<_InputIterator>, | |
580 | typename = _RequireAllocator<_Allocator>> | |
581 | multimap(_InputIterator, _InputIterator, | |
582 | _Compare = _Compare(), _Allocator = _Allocator()) | |
583 | -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, | |
584 | _Compare, _Allocator>; | |
585 | ||
586 | template<typename _Key, typename _Tp, typename _Compare = less<_Key>, | |
587 | typename _Allocator = allocator<pair<const _Key, _Tp>>, | |
588 | typename = _RequireAllocator<_Allocator>> | |
589 | multimap(initializer_list<pair<_Key, _Tp>>, | |
590 | _Compare = _Compare(), _Allocator = _Allocator()) | |
591 | -> multimap<_Key, _Tp, _Compare, _Allocator>; | |
592 | ||
593 | template<typename _InputIterator, typename _Allocator, | |
594 | typename = _RequireInputIter<_InputIterator>, | |
595 | typename = _RequireAllocator<_Allocator>> | |
596 | multimap(_InputIterator, _InputIterator, _Allocator) | |
597 | -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, | |
598 | less<__iter_key_t<_InputIterator>>, _Allocator>; | |
599 | ||
600 | template<typename _Key, typename _Tp, typename _Allocator, | |
601 | typename = _RequireAllocator<_Allocator>> | |
602 | multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) | |
603 | -> multimap<_Key, _Tp, less<_Key>, _Allocator>; | |
604 | ||
605 | #endif | |
606 | ||
ed540c0a CJ |
607 | template<typename _Key, typename _Tp, |
608 | typename _Compare, typename _Allocator> | |
285b36d6 | 609 | inline bool |
ed540c0a CJ |
610 | operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
611 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
612 | { return __lhs._M_base() == __rhs._M_base(); } |
613 | ||
ed540c0a CJ |
614 | template<typename _Key, typename _Tp, |
615 | typename _Compare, typename _Allocator> | |
285b36d6 | 616 | inline bool |
ed540c0a CJ |
617 | operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
618 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
619 | { return __lhs._M_base() != __rhs._M_base(); } |
620 | ||
ed540c0a CJ |
621 | template<typename _Key, typename _Tp, |
622 | typename _Compare, typename _Allocator> | |
285b36d6 | 623 | inline bool |
ed540c0a CJ |
624 | operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
625 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
626 | { return __lhs._M_base() < __rhs._M_base(); } |
627 | ||
ed540c0a CJ |
628 | template<typename _Key, typename _Tp, |
629 | typename _Compare, typename _Allocator> | |
285b36d6 | 630 | inline bool |
ed540c0a CJ |
631 | operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
632 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
633 | { return __lhs._M_base() <= __rhs._M_base(); } |
634 | ||
ed540c0a CJ |
635 | template<typename _Key, typename _Tp, |
636 | typename _Compare, typename _Allocator> | |
285b36d6 | 637 | inline bool |
ed540c0a CJ |
638 | operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
639 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
640 | { return __lhs._M_base() >= __rhs._M_base(); } |
641 | ||
ed540c0a CJ |
642 | template<typename _Key, typename _Tp, |
643 | typename _Compare, typename _Allocator> | |
285b36d6 | 644 | inline bool |
ed540c0a CJ |
645 | operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
646 | const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
285b36d6 BK |
647 | { return __lhs._M_base() > __rhs._M_base(); } |
648 | ||
ed540c0a CJ |
649 | template<typename _Key, typename _Tp, |
650 | typename _Compare, typename _Allocator> | |
285b36d6 | 651 | inline void |
ed540c0a CJ |
652 | swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs, |
653 | multimap<_Key, _Tp, _Compare, _Allocator>& __rhs) | |
c5d9ec56 | 654 | _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) |
285b36d6 | 655 | { __lhs.swap(__rhs); } |
ed540c0a | 656 | |
45f388bb | 657 | } // namespace __debug |
3cbc7af0 | 658 | } // namespace std |
285b36d6 | 659 | |
526da49c | 660 | #endif |