]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/debug/multimap.h
Do not query further vector epilogues after a masked epilogue
[thirdparty/gcc.git] / libstdc++-v3 / include / debug / multimap.h
CommitLineData
285b36d6
BK
1// Debugging multimap implementation -*- C++ -*-
2
6441eb6d 3// Copyright (C) 2003-2025 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 34#include <debug/safe_iterator.h>
16158c96 35#include <bits/stl_pair.h>
285b36d6 36
12ffa228 37namespace std _GLIBCXX_VISIBILITY(default)
3cbc7af0 38{
45f388bb 39namespace __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
e9afbed0
FD
59 template<typename _ItT, typename _SeqT, typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
61
eca833b8
JW
62 // Reference wrapper for base class. Disambiguates multimap(const _Base&)
63 // from copy constructor by requiring a user-defined conversion.
64 // See PR libstdc++/90102.
65 struct _Base_ref
66 {
67 _Base_ref(const _Base& __r) : _M_ref(__r) { }
68
69 const _Base& _M_ref;
70 };
71
285b36d6
BK
72 public:
73 // types:
15ee1a77
FD
74 typedef _Key key_type;
75 typedef _Tp mapped_type;
76 typedef std::pair<const _Key, _Tp> value_type;
77 typedef _Compare key_compare;
78 typedef _Allocator allocator_type;
79 typedef typename _Base::reference reference;
80 typedef typename _Base::const_reference const_reference;
526da49c 81
afe96d41 82 typedef __gnu_debug::_Safe_iterator<_Base_iterator, multimap>
15ee1a77 83 iterator;
afe96d41 84 typedef __gnu_debug::_Safe_iterator<_Base_const_iterator,
15ee1a77 85 multimap> const_iterator;
285b36d6 86
15ee1a77
FD
87 typedef typename _Base::size_type size_type;
88 typedef typename _Base::difference_type difference_type;
89 typedef typename _Base::pointer pointer;
90 typedef typename _Base::const_pointer const_pointer;
91 typedef std::reverse_iterator<iterator> reverse_iterator;
92 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
526da49c 93
285b36d6 94 // 23.3.1.1 construct/copy/destroy:
c3cdd71f 95
15ee1a77 96#if __cplusplus < 201103L
c3cdd71f
JW
97 multimap() : _Base() { }
98
ed540c0a 99 multimap(const multimap& __x)
4c2d93db 100 : _Base(__x) { }
285b36d6 101
15ee1a77
FD
102 ~multimap() { }
103#else
104 multimap() = default;
105 multimap(const multimap&) = default;
106 multimap(multimap&&) = default;
988499f4
JM
107
108 multimap(initializer_list<value_type> __l,
109 const _Compare& __c = _Compare(),
110 const allocator_type& __a = allocator_type())
4c2d93db 111 : _Base(__l, __c, __a) { }
51835a80
FD
112
113 explicit
114 multimap(const allocator_type& __a)
115 : _Base(__a) { }
116
22d34a2a
JW
117 multimap(const multimap& __m,
118 const __type_identity_t<allocator_type>& __a)
51835a80
FD
119 : _Base(__m, __a) { }
120
22d34a2a 121 multimap(multimap&& __m, const __type_identity_t<allocator_type>& __a)
e9a53a4f
FD
122 noexcept( noexcept(_Base(std::move(__m), __a)) )
123 : _Safe(std::move(__m), __a),
124 _Base(std::move(__m), __a) { }
51835a80
FD
125
126 multimap(initializer_list<value_type> __l, const allocator_type& __a)
15ee1a77 127 : _Base(__l, __a) { }
51835a80
FD
128
129 template<typename _InputIterator>
15ee1a77 130 multimap(_InputIterator __first, _InputIterator __last,
51835a80 131 const allocator_type& __a)
90aabc7e
FD
132 : _Base(__gnu_debug::__base(
133 __glibcxx_check_valid_constructor_range(__first, __last)),
15ee1a77
FD
134 __gnu_debug::__base(__last), __a) { }
135
ae54d8cb 136#if __glibcxx_containers_ranges // C++ >= 23
f3253bd7
JW
137 /**
138 * @brief Construct a multimap from a range.
139 * @since C++23
140 */
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
142 multimap(std::from_range_t __t, _Rg&& __rg,
143 const _Compare& __c,
144 const allocator_type& __a = allocator_type())
145 : _Base(__t, std::forward<_Rg>(__rg), __c, __a)
146 { }
147
148 template<std::__detail::__container_compatible_range<value_type> _Rg>
149 multimap(std::from_range_t __t, _Rg&& __rg,
150 const allocator_type& __a = allocator_type())
151 : _Base(__t, std::forward<_Rg>(__rg), __a)
152 { }
153#endif
154
15ee1a77 155 ~multimap() = default;
ed540c0a 156#endif
285b36d6 157
15ee1a77
FD
158 explicit multimap(const _Compare& __comp,
159 const _Allocator& __a = _Allocator())
160 : _Base(__comp, __a) { }
161
162 template<typename _InputIterator>
163 multimap(_InputIterator __first, _InputIterator __last,
164 const _Compare& __comp = _Compare(),
165 const _Allocator& __a = _Allocator())
90aabc7e
FD
166 : _Base(__gnu_debug::__base(
167 __glibcxx_check_valid_constructor_range(__first, __last)),
15ee1a77
FD
168 __gnu_debug::__base(__last),
169 __comp, __a) { }
170
eca833b8
JW
171 multimap(_Base_ref __x)
172 : _Base(__x._M_ref) { }
285b36d6 173
4a407d35 174#if __cplusplus >= 201103L
15ee1a77
FD
175 multimap&
176 operator=(const multimap&) = default;
285b36d6 177
ed540c0a 178 multimap&
15ee1a77 179 operator=(multimap&&) = default;
988499f4
JM
180
181 multimap&
182 operator=(initializer_list<value_type> __l)
183 {
e9a53a4f 184 _Base::operator=(__l);
51835a80 185 this->_M_invalidate_all();
988499f4
JM
186 return *this;
187 }
ed540c0a
CJ
188#endif
189
285b36d6
BK
190 using _Base::get_allocator;
191
192 // iterators:
526da49c 193 iterator
d3677132 194 begin() _GLIBCXX_NOEXCEPT
285b36d6
BK
195 { return iterator(_Base::begin(), this); }
196
526da49c 197 const_iterator
d3677132 198 begin() const _GLIBCXX_NOEXCEPT
285b36d6
BK
199 { return const_iterator(_Base::begin(), this); }
200
526da49c 201 iterator
d3677132 202 end() _GLIBCXX_NOEXCEPT
285b36d6
BK
203 { return iterator(_Base::end(), this); }
204
526da49c 205 const_iterator
d3677132 206 end() const _GLIBCXX_NOEXCEPT
285b36d6
BK
207 { return const_iterator(_Base::end(), this); }
208
526da49c 209 reverse_iterator
d3677132 210 rbegin() _GLIBCXX_NOEXCEPT
285b36d6
BK
211 { return reverse_iterator(end()); }
212
526da49c 213 const_reverse_iterator
d3677132 214 rbegin() const _GLIBCXX_NOEXCEPT
285b36d6
BK
215 { return const_reverse_iterator(end()); }
216
526da49c 217 reverse_iterator
d3677132 218 rend() _GLIBCXX_NOEXCEPT
285b36d6
BK
219 { return reverse_iterator(begin()); }
220
526da49c 221 const_reverse_iterator
d3677132 222 rend() const _GLIBCXX_NOEXCEPT
285b36d6
BK
223 { return const_reverse_iterator(begin()); }
224
734f5023 225#if __cplusplus >= 201103L
0cd50f89 226 const_iterator
d3677132 227 cbegin() const noexcept
0cd50f89
PC
228 { return const_iterator(_Base::begin(), this); }
229
230 const_iterator
d3677132 231 cend() const noexcept
0cd50f89
PC
232 { return const_iterator(_Base::end(), this); }
233
234 const_reverse_iterator
d3677132 235 crbegin() const noexcept
0cd50f89
PC
236 { return const_reverse_iterator(end()); }
237
238 const_reverse_iterator
d3677132 239 crend() const noexcept
0cd50f89
PC
240 { return const_reverse_iterator(begin()); }
241#endif
242
285b36d6
BK
243 // capacity:
244 using _Base::empty;
245 using _Base::size;
246 using _Base::max_size;
247
248 // modifiers:
734f5023 249#if __cplusplus >= 201103L
55826ab6
FD
250 template<typename... _Args>
251 iterator
252 emplace(_Args&&... __args)
784779d4 253 { return { _Base::emplace(std::forward<_Args>(__args)...), this }; }
55826ab6
FD
254
255 template<typename... _Args>
256 iterator
257 emplace_hint(const_iterator __pos, _Args&&... __args)
258 {
259 __glibcxx_check_insert(__pos);
784779d4
FD
260 return
261 {
262 _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...),
263 this
264 };
55826ab6
FD
265 }
266#endif
15ee1a77 267
526da49c 268 iterator
285b36d6
BK
269 insert(const value_type& __x)
270 { return iterator(_Base::insert(__x), this); }
271
734f5023 272#if __cplusplus >= 201103L
1679da15
FD
273 // _GLIBCXX_RESOLVE_LIB_DEFECTS
274 // 2354. Unnecessary copying when inserting into maps with braced-init
275 iterator
276 insert(value_type&& __x)
277 { return { _Base::insert(std::move(__x)), this }; }
278
e6a05448 279 template<typename _Pair, typename = typename
57cee56a
PC
280 std::enable_if<std::is_constructible<value_type,
281 _Pair&&>::value>::type>
15ee1a77
FD
282 iterator
283 insert(_Pair&& __x)
784779d4 284 { return { _Base::insert(std::forward<_Pair>(__x)), this }; }
e6a05448
PC
285#endif
286
734f5023 287#if __cplusplus >= 201103L
988499f4
JM
288 void
289 insert(std::initializer_list<value_type> __list)
290 { _Base::insert(__list); }
291#endif
292
526da49c 293 iterator
734f5023 294#if __cplusplus >= 201103L
6b6d5d09
PC
295 insert(const_iterator __position, const value_type& __x)
296#else
afe96d41 297 insert(iterator __position, const value_type& __x)
6b6d5d09 298#endif
285b36d6
BK
299 {
300 __glibcxx_check_insert(__position);
301 return iterator(_Base::insert(__position.base(), __x), this);
302 }
303
734f5023 304#if __cplusplus >= 201103L
1679da15
FD
305 // _GLIBCXX_RESOLVE_LIB_DEFECTS
306 // 2354. Unnecessary copying when inserting into maps with braced-init
307 iterator
308 insert(const_iterator __position, value_type&& __x)
309 {
310 __glibcxx_check_insert(__position);
311 return { _Base::insert(__position.base(), std::move(__x)), this };
312 }
313
e6a05448 314 template<typename _Pair, typename = typename
57cee56a
PC
315 std::enable_if<std::is_constructible<value_type,
316 _Pair&&>::value>::type>
15ee1a77
FD
317 iterator
318 insert(const_iterator __position, _Pair&& __x)
319 {
e6a05448 320 __glibcxx_check_insert(__position);
784779d4
FD
321 return
322 {
323 _Base::insert(__position.base(), std::forward<_Pair>(__x)),
324 this
325 };
e6a05448
PC
326 }
327#endif
328
285b36d6 329 template<typename _InputIterator>
15ee1a77
FD
330 void
331 insert(_InputIterator __first, _InputIterator __last)
332 {
24167c42
FD
333 typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
334 __glibcxx_check_valid_range2(__first, __last, __dist);
335
336 if (__dist.second >= __gnu_debug::__dp_sign)
337 _Base::insert(__gnu_debug::__unsafe(__first),
338 __gnu_debug::__unsafe(__last));
339 else
340 _Base::insert(__first, __last);
285b36d6
BK
341 }
342
2dbe56bd
JW
343#if __cplusplus > 201402L
344 using node_type = typename _Base::node_type;
345
346 node_type
347 extract(const_iterator __position)
348 {
349 __glibcxx_check_erase(__position);
350 this->_M_invalidate_if(_Equal(__position.base()));
351 return _Base::extract(__position.base());
352 }
353
354 node_type
355 extract(const key_type& __key)
356 {
357 const auto __position = find(__key);
358 if (__position != end())
359 return extract(__position);
360 return {};
361 }
362
363 iterator
364 insert(node_type&& __nh)
784779d4 365 { return { _Base::insert(std::move(__nh)), this }; }
2dbe56bd
JW
366
367 iterator
368 insert(const_iterator __hint, node_type&& __nh)
369 {
370 __glibcxx_check_insert(__hint);
784779d4 371 return { _Base::insert(__hint.base(), std::move(__nh)), this };
2dbe56bd
JW
372 }
373
374 using _Base::merge;
375#endif // C++17
376
734f5023 377#if __cplusplus >= 201103L
5ab06c6d 378 iterator
6b6d5d09 379 erase(const_iterator __position)
5ab06c6d
PC
380 {
381 __glibcxx_check_erase(__position);
5f40d34b
FD
382 return { erase(__position.base()), this };
383 }
384
385 _Base_iterator
386 erase(_Base_const_iterator __position)
387 {
388 __glibcxx_check_erase2(__position);
389 this->_M_invalidate_if(_Equal(__position));
390 return _Base::erase(__position);
5ab06c6d 391 }
6dc88283 392
7b1e8acf 393 _GLIBCXX_ABI_TAG_CXX11
6dc88283
PC
394 iterator
395 erase(iterator __position)
396 { return erase(const_iterator(__position)); }
5ab06c6d 397#else
526da49c 398 void
285b36d6
BK
399 erase(iterator __position)
400 {
401 __glibcxx_check_erase(__position);
afe96d41 402 this->_M_invalidate_if(_Equal(__position.base()));
285b36d6
BK
403 _Base::erase(__position.base());
404 }
5ab06c6d 405#endif
285b36d6 406
526da49c 407 size_type
285b36d6
BK
408 erase(const key_type& __x)
409 {
afe96d41
FD
410 std::pair<_Base_iterator, _Base_iterator> __victims =
411 _Base::equal_range(__x);
285b36d6 412 size_type __count = 0;
afe96d41
FD
413 _Base_iterator __victim = __victims.first;
414 while (__victim != __victims.second)
415 {
416 this->_M_invalidate_if(_Equal(__victim));
417 _Base::erase(__victim++);
418 ++__count;
419 }
285b36d6
BK
420 return __count;
421 }
422
734f5023 423#if __cplusplus >= 201103L
5ab06c6d 424 iterator
6b6d5d09 425 erase(const_iterator __first, const_iterator __last)
5ab06c6d
PC
426 {
427 // _GLIBCXX_RESOLVE_LIB_DEFECTS
428 // 151. can't currently clear() empty container
429 __glibcxx_check_erase_range(__first, __last);
afe96d41
FD
430 for (_Base_const_iterator __victim = __first.base();
431 __victim != __last.base(); ++__victim)
432 {
e0b9bc23 433 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::cend(),
afe96d41
FD
434 _M_message(__gnu_debug::__msg_valid_range)
435 ._M_iterator(__first, "first")
436 ._M_iterator(__last, "last"));
437 this->_M_invalidate_if(_Equal(__victim));
438 }
784779d4
FD
439
440 return { _Base::erase(__first.base(), __last.base()), this };
5ab06c6d
PC
441 }
442#else
526da49c 443 void
285b36d6
BK
444 erase(iterator __first, iterator __last)
445 {
446 // _GLIBCXX_RESOLVE_LIB_DEFECTS
447 // 151. can't currently clear() empty container
448 __glibcxx_check_erase_range(__first, __last);
afe96d41
FD
449 for (_Base_iterator __victim = __first.base();
450 __victim != __last.base(); ++__victim)
451 {
452 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
453 _M_message(__gnu_debug::__msg_valid_range)
454 ._M_iterator(__first, "first")
455 ._M_iterator(__last, "last"));
456 this->_M_invalidate_if(_Equal(__victim));
457 }
458 _Base::erase(__first.base(), __last.base());
285b36d6 459 }
5ab06c6d 460#endif
285b36d6 461
526da49c 462 void
ed540c0a 463 swap(multimap& __x)
c5d9ec56 464 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
285b36d6 465 {
15ee1a77 466 _Safe::_M_swap(__x);
285b36d6 467 _Base::swap(__x);
285b36d6
BK
468 }
469
526da49c 470 void
d3677132 471 clear() _GLIBCXX_NOEXCEPT
afe96d41
FD
472 {
473 this->_M_invalidate_all();
474 _Base::clear();
475 }
285b36d6
BK
476
477 // observers:
478 using _Base::key_comp;
479 using _Base::value_comp;
480
481 // 23.3.1.3 multimap operations:
526da49c 482 iterator
285b36d6
BK
483 find(const key_type& __x)
484 { return iterator(_Base::find(__x), this); }
485
d7b35f22
FD
486#if __cplusplus > 201103L
487 template<typename _Kt,
488 typename _Req =
489 typename __has_is_transparent<_Compare, _Kt>::type>
490 iterator
491 find(const _Kt& __x)
492 { return { _Base::find(__x), this }; }
493#endif
494
526da49c 495 const_iterator
285b36d6
BK
496 find(const key_type& __x) const
497 { return const_iterator(_Base::find(__x), this); }
498
d7b35f22
FD
499#if __cplusplus > 201103L
500 template<typename _Kt,
501 typename _Req =
502 typename __has_is_transparent<_Compare, _Kt>::type>
503 const_iterator
504 find(const _Kt& __x) const
505 { return { _Base::find(__x), this }; }
506#endif
507
285b36d6
BK
508 using _Base::count;
509
526da49c 510 iterator
285b36d6
BK
511 lower_bound(const key_type& __x)
512 { return iterator(_Base::lower_bound(__x), this); }
513
d7b35f22
FD
514#if __cplusplus > 201103L
515 template<typename _Kt,
516 typename _Req =
517 typename __has_is_transparent<_Compare, _Kt>::type>
518 iterator
519 lower_bound(const _Kt& __x)
520 { return { _Base::lower_bound(__x), this }; }
521#endif
522
526da49c 523 const_iterator
285b36d6
BK
524 lower_bound(const key_type& __x) const
525 { return const_iterator(_Base::lower_bound(__x), this); }
526
d7b35f22
FD
527#if __cplusplus > 201103L
528 template<typename _Kt,
529 typename _Req =
530 typename __has_is_transparent<_Compare, _Kt>::type>
531 const_iterator
532 lower_bound(const _Kt& __x) const
533 { return { _Base::lower_bound(__x), this }; }
534#endif
535
526da49c 536 iterator
285b36d6
BK
537 upper_bound(const key_type& __x)
538 { return iterator(_Base::upper_bound(__x), this); }
539
d7b35f22
FD
540#if __cplusplus > 201103L
541 template<typename _Kt,
542 typename _Req =
543 typename __has_is_transparent<_Compare, _Kt>::type>
544 iterator
545 upper_bound(const _Kt& __x)
546 { return { _Base::upper_bound(__x), this }; }
547#endif
548
526da49c 549 const_iterator
285b36d6
BK
550 upper_bound(const key_type& __x) const
551 { return const_iterator(_Base::upper_bound(__x), this); }
552
d7b35f22
FD
553#if __cplusplus > 201103L
554 template<typename _Kt,
555 typename _Req =
556 typename __has_is_transparent<_Compare, _Kt>::type>
557 const_iterator
558 upper_bound(const _Kt& __x) const
559 { return { _Base::upper_bound(__x), this }; }
560#endif
561
285b36d6
BK
562 std::pair<iterator,iterator>
563 equal_range(const key_type& __x)
564 {
285b36d6
BK
565 std::pair<_Base_iterator, _Base_iterator> __res =
566 _Base::equal_range(__x);
567 return std::make_pair(iterator(__res.first, this),
568 iterator(__res.second, this));
569 }
570
d7b35f22
FD
571#if __cplusplus > 201103L
572 template<typename _Kt,
573 typename _Req =
574 typename __has_is_transparent<_Compare, _Kt>::type>
575 std::pair<iterator, iterator>
576 equal_range(const _Kt& __x)
577 {
578 auto __res = _Base::equal_range(__x);
579 return { { __res.first, this }, { __res.second, this } };
580 }
581#endif
582
285b36d6
BK
583 std::pair<const_iterator,const_iterator>
584 equal_range(const key_type& __x) const
585 {
285b36d6 586 std::pair<_Base_const_iterator, _Base_const_iterator> __res =
afe96d41 587 _Base::equal_range(__x);
285b36d6
BK
588 return std::make_pair(const_iterator(__res.first, this),
589 const_iterator(__res.second, this));
590 }
591
d7b35f22
FD
592#if __cplusplus > 201103L
593 template<typename _Kt,
594 typename _Req =
595 typename __has_is_transparent<_Compare, _Kt>::type>
596 std::pair<const_iterator, const_iterator>
597 equal_range(const _Kt& __x) const
598 {
599 auto __res = _Base::equal_range(__x);
600 return { { __res.first, this }, { __res.second, this } };
601 }
602#endif
603
526da49c 604 _Base&
15ee1a77 605 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
285b36d6 606
526da49c 607 const _Base&
d3677132 608 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
285b36d6
BK
609 };
610
957f5fea
VV
611#if __cpp_deduction_guides >= 201606
612
613 template<typename _InputIterator,
614 typename _Compare = less<__iter_key_t<_InputIterator>>,
615 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
616 typename = _RequireInputIter<_InputIterator>,
c0cb38c2 617 typename = _RequireNotAllocator<_Compare>,
957f5fea
VV
618 typename = _RequireAllocator<_Allocator>>
619 multimap(_InputIterator, _InputIterator,
620 _Compare = _Compare(), _Allocator = _Allocator())
621 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
622 _Compare, _Allocator>;
623
624 template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
625 typename _Allocator = allocator<pair<const _Key, _Tp>>,
c0cb38c2 626 typename = _RequireNotAllocator<_Compare>,
957f5fea
VV
627 typename = _RequireAllocator<_Allocator>>
628 multimap(initializer_list<pair<_Key, _Tp>>,
629 _Compare = _Compare(), _Allocator = _Allocator())
630 -> multimap<_Key, _Tp, _Compare, _Allocator>;
631
632 template<typename _InputIterator, typename _Allocator,
633 typename = _RequireInputIter<_InputIterator>,
634 typename = _RequireAllocator<_Allocator>>
635 multimap(_InputIterator, _InputIterator, _Allocator)
636 -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
637 less<__iter_key_t<_InputIterator>>, _Allocator>;
638
639 template<typename _Key, typename _Tp, typename _Allocator,
640 typename = _RequireAllocator<_Allocator>>
641 multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
642 -> multimap<_Key, _Tp, less<_Key>, _Allocator>;
643
ae54d8cb 644#if __glibcxx_containers_ranges // C++ >= 23
f3253bd7
JW
645 template<ranges::input_range _Rg,
646 __not_allocator_like _Compare = less<__detail::__range_key_type<_Rg>>,
647 __allocator_like _Alloc =
648 std::allocator<__detail::__range_to_alloc_type<_Rg>>>
649 multimap(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
650 -> multimap<__detail::__range_key_type<_Rg>,
651 __detail::__range_mapped_type<_Rg>,
652 _Compare, _Alloc>;
653
654 template<ranges::input_range _Rg, __allocator_like _Alloc>
655 multimap(from_range_t, _Rg&&, _Alloc)
656 -> multimap<__detail::__range_key_type<_Rg>,
657 __detail::__range_mapped_type<_Rg>,
658 less<__detail::__range_key_type<_Rg>>,
659 _Alloc>;
660#endif
957f5fea
VV
661#endif
662
ed540c0a
CJ
663 template<typename _Key, typename _Tp,
664 typename _Compare, typename _Allocator>
285b36d6 665 inline bool
ed540c0a
CJ
666 operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
667 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6
BK
668 { return __lhs._M_base() == __rhs._M_base(); }
669
93843da6
JW
670#if __cpp_lib_three_way_comparison
671 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
672 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
673 operator<=>(const multimap<_Key, _Tp, _Compare, _Alloc>& __lhs,
674 const multimap<_Key, _Tp, _Compare, _Alloc>& __rhs)
675 { return __lhs._M_base() <=> __rhs._M_base(); }
676#else
ed540c0a
CJ
677 template<typename _Key, typename _Tp,
678 typename _Compare, typename _Allocator>
285b36d6 679 inline bool
ed540c0a
CJ
680 operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
681 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6
BK
682 { return __lhs._M_base() != __rhs._M_base(); }
683
ed540c0a
CJ
684 template<typename _Key, typename _Tp,
685 typename _Compare, typename _Allocator>
285b36d6 686 inline bool
ed540c0a
CJ
687 operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
688 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6
BK
689 { return __lhs._M_base() < __rhs._M_base(); }
690
ed540c0a
CJ
691 template<typename _Key, typename _Tp,
692 typename _Compare, typename _Allocator>
285b36d6 693 inline bool
ed540c0a
CJ
694 operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
695 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6
BK
696 { return __lhs._M_base() <= __rhs._M_base(); }
697
ed540c0a
CJ
698 template<typename _Key, typename _Tp,
699 typename _Compare, typename _Allocator>
285b36d6 700 inline bool
ed540c0a
CJ
701 operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
702 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6
BK
703 { return __lhs._M_base() >= __rhs._M_base(); }
704
ed540c0a
CJ
705 template<typename _Key, typename _Tp,
706 typename _Compare, typename _Allocator>
285b36d6 707 inline bool
ed540c0a
CJ
708 operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
709 const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
285b36d6 710 { return __lhs._M_base() > __rhs._M_base(); }
93843da6 711#endif // three-way comparison
285b36d6 712
ed540c0a
CJ
713 template<typename _Key, typename _Tp,
714 typename _Compare, typename _Allocator>
285b36d6 715 inline void
ed540c0a
CJ
716 swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
717 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
c5d9ec56 718 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
285b36d6 719 { __lhs.swap(__rhs); }
ed540c0a 720
45f388bb 721} // namespace __debug
3cbc7af0 722} // namespace std
285b36d6 723
526da49c 724#endif