libstdc++
GNU C++ library
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1// Debugging map implementation -*- C++ -*-
2
3// Copyright (C) 2003-2026 Free Software Foundation, Inc.
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
8// Free Software Foundation; either version 3, or (at your option)
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
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/>.
24
25/** @file debug/map.h
26 * This file is a GNU debug extension to the Standard C++ Library.
27 */
28
29#ifndef _GLIBCXX_DEBUG_MAP_H
30#define _GLIBCXX_DEBUG_MAP_H 1
31
32#include <debug/safe_sequence.h>
34#include <debug/safe_iterator.h>
35#include <bits/stl_pair.h>
36
37namespace std _GLIBCXX_VISIBILITY(default)
38{
39namespace __debug
40{
41 /// Class std::map with safety/checking/debug instrumentation.
42 template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
43 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
44 class map
46 map<_Key, _Tp, _Compare, _Allocator>, _Allocator,
47 __gnu_debug::_Safe_node_sequence>,
48 public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
49 {
50 typedef _GLIBCXX_STD_C::map<
51 _Key, _Tp, _Compare, _Allocator> _Base;
54
58
59 template<typename _ItT, typename _SeqT, typename _CatT>
60 friend class ::__gnu_debug::_Safe_iterator;
61
62 // Reference wrapper for base class. Disambiguates map(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
72 public:
73 // types:
74 typedef _Key key_type;
75 typedef _Tp mapped_type;
78 typedef _Allocator allocator_type;
79 typedef typename _Base::reference reference;
81
86
87 typedef typename _Base::size_type size_type;
89 typedef typename _Base::pointer pointer;
93
94 // 23.3.1.1 construct/copy/destroy:
95
96#if __cplusplus < 201103L
97 map() : _Base() { }
98
99 map(const map& __x)
100 : _Base(__x) { }
101
102 ~map() { }
103#else
104 map() = default;
105 map(const map&) = default;
106 map(map&&) = default;
107
109 const _Compare& __c = _Compare(),
110 const allocator_type& __a = allocator_type())
111 : _Base(__l, __c, __a) { }
112
113 explicit
114 map(const allocator_type& __a)
115 : _Base(__a) { }
116
117 map(const map& __m, const __type_identity_t<allocator_type>& __a)
118 : _Base(__m, __a) { }
119
120 map(map&& __m, const __type_identity_t<allocator_type>& __a)
121 noexcept( noexcept(_Base(std::move(__m), __a)) )
122 : _Safe(std::move(__m), __a),
123 _Base(std::move(__m), __a) { }
124
126 : _Base(__l, __a) { }
127
128 template<typename _InputIterator>
129 map(_InputIterator __first, _InputIterator __last,
130 const allocator_type& __a)
131 : _Base(__gnu_debug::__base(
133 __gnu_debug::__base(__last), __a)
134 { }
135
136#if __glibcxx_containers_ranges // C++ >= 23
137 /**
138 * @brief Construct a map from a range.
139 * @since C++23
140 */
141 template<std::__detail::__container_compatible_range<value_type> _Rg>
142 map(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 map(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
155 ~map() = default;
156#endif
157
159 : _Base(__x._M_ref) { }
160
161 explicit map(const _Compare& __comp,
162 const _Allocator& __a = _Allocator())
163 : _Base(__comp, __a) { }
164
165 template<typename _InputIterator>
166 map(_InputIterator __first, _InputIterator __last,
167 const _Compare& __comp = _Compare(),
168 const _Allocator& __a = _Allocator())
169 : _Base(__gnu_debug::__base(
171 __gnu_debug::__base(__last),
172 __comp, __a) { }
173
174#if __cplusplus >= 201103L
175 map&
176 operator=(const map&) = default;
177
178 map&
179 operator=(map&&) = default;
180
181 map&
183 {
184 _Base::operator=(__l);
185 this->_M_invalidate_all();
186 return *this;
187 }
188#endif
189
190 // _GLIBCXX_RESOLVE_LIB_DEFECTS
191 // 133. map missing get_allocator()
192 using _Base::get_allocator;
193
194 // iterators:
196 begin() _GLIBCXX_NOEXCEPT
197 { return iterator(_Base::begin(), this); }
198
199 const_iterator
200 begin() const _GLIBCXX_NOEXCEPT
201 { return const_iterator(_Base::begin(), this); }
202
204 end() _GLIBCXX_NOEXCEPT
205 { return iterator(_Base::end(), this); }
206
207 const_iterator
208 end() const _GLIBCXX_NOEXCEPT
209 { return const_iterator(_Base::end(), this); }
210
212 rbegin() _GLIBCXX_NOEXCEPT
213 { return reverse_iterator(end()); }
214
216 rbegin() const _GLIBCXX_NOEXCEPT
217 { return const_reverse_iterator(end()); }
218
220 rend() _GLIBCXX_NOEXCEPT
221 { return reverse_iterator(begin()); }
222
224 rend() const _GLIBCXX_NOEXCEPT
225 { return const_reverse_iterator(begin()); }
226
227#if __cplusplus >= 201103L
228 const_iterator
229 cbegin() const noexcept
230 { return const_iterator(_Base::begin(), this); }
231
232 const_iterator
233 cend() const noexcept
234 { return const_iterator(_Base::end(), this); }
235
237 crbegin() const noexcept
238 { return const_reverse_iterator(end()); }
239
241 crend() const noexcept
242 { return const_reverse_iterator(begin()); }
243#endif
244
245 // capacity:
246 using _Base::empty;
247 using _Base::size;
248 using _Base::max_size;
249
250 // 23.3.1.2 element access:
251 using _Base::operator[];
252
253 // _GLIBCXX_RESOLVE_LIB_DEFECTS
254 // DR 464. Suggestion for new member functions in standard containers.
255 using _Base::at;
256
257 // modifiers:
258#if __cplusplus >= 201103L
259 template<typename... _Args>
261 emplace(_Args&&... __args)
262 {
263 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
264 return { { __res.first, this }, __res.second };
265 }
266
267 template<typename... _Args>
269 emplace_hint(const_iterator __pos, _Args&&... __args)
270 {
272 return
273 {
274 _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...),
275 this
276 };
277 }
278#endif
279
281 insert(const value_type& __x)
282 {
284 return std::pair<iterator, bool>(iterator(__res.first, this),
285 __res.second);
286 }
287
288#if __cplusplus >= 201103L
289 // _GLIBCXX_RESOLVE_LIB_DEFECTS
290 // 2354. Unnecessary copying when inserting into maps with braced-init
293 {
294 auto __res = _Base::insert(std::move(__x));
295 return { { __res.first, this }, __res.second };
296 }
297
298 template<typename _Pair, typename = typename
300 _Pair&&>::value>::type>
302 insert(_Pair&& __x)
303 {
304 auto __res = _Base::insert(std::forward<_Pair>(__x));
305 return { { __res.first, this }, __res.second };
306 }
307#endif
308
309#if __cplusplus >= 201103L
310 void
313#endif
314
316#if __cplusplus >= 201103L
317 insert(const_iterator __position, const value_type& __x)
318#else
319 insert(iterator __position, const value_type& __x)
320#endif
321 {
322 __glibcxx_check_insert(__position);
323 return iterator(_Base::insert(__position.base(), __x), this);
324 }
325
326#if __cplusplus >= 201103L
327 // _GLIBCXX_RESOLVE_LIB_DEFECTS
328 // 2354. Unnecessary copying when inserting into maps with braced-init
331 {
332 __glibcxx_check_insert(__position);
333 return { _Base::insert(__position.base(), std::move(__x)), this };
334 }
335
336 template<typename _Pair, typename = typename
338 _Pair&&>::value>::type>
340 insert(const_iterator __position, _Pair&& __x)
341 {
342 __glibcxx_check_insert(__position);
343 return
344 {
345 _Base::insert(__position.base(), std::forward<_Pair>(__x)),
346 this
347 };
348 }
349#endif
350
351 template<typename _InputIterator>
352 void
353 insert(_InputIterator __first, _InputIterator __last)
354 {
356 __glibcxx_check_valid_range2(__first, __last, __dist);
357
358 if (__dist.second >= __gnu_debug::__dp_sign)
360 __gnu_debug::__unsafe(__last));
361 else
362 _Base::insert(__first, __last);
363 }
364
365
366#ifdef __glibcxx_map_try_emplace // C++ >= 17 && HOSTED
367 template <typename... _Args>
369 try_emplace(const key_type& __k, _Args&&... __args)
370 {
371 auto __res = _Base::try_emplace(__k,
372 std::forward<_Args>(__args)...);
373 return { { __res.first, this }, __res.second };
374 }
375
376 template <typename... _Args>
378 try_emplace(key_type&& __k, _Args&&... __args)
379 {
380 auto __res = _Base::try_emplace(std::move(__k),
381 std::forward<_Args>(__args)...);
382 return { { __res.first, this }, __res.second };
383 }
384
385# ifdef __glibcxx_associative_heterogeneous_insertion
386 template <__heterogeneous_tree_key<map> _Kt, typename... _Args>
388 try_emplace(_Kt&& __k, _Args&&... __args)
389 {
390 auto __res = _Base::try_emplace(
391 std::forward<_Kt>(__k), std::forward<_Args>(__args)...);
392 return { { __res.first, this }, __res.second };
393 }
394#endif
395
396 template <typename... _Args>
398 try_emplace(const_iterator __hint, const key_type& __k,
399 _Args&&... __args)
400 {
402 auto __it = _Base::try_emplace(__hint.base(), __k,
403 std::forward<_Args>(__args)...);
404 return { __it, this };
405 }
406
407 template <typename... _Args>
409 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
410 {
412 auto __it = _Base::try_emplace(__hint.base(), std::move(__k),
413 std::forward<_Args>(__args)...);
414 return { __it, this };
415 }
416
417# ifdef __glibcxx_associative_heterogeneous_insertion
418 template <__heterogeneous_tree_key<map> _Kt, typename... _Args>
420 try_emplace(const_iterator __hint, _Kt&& __k, _Args&&... __args)
421 {
423 auto __it = _Base::try_emplace(__hint.base(),
424 std::forward<_Kt>(__k), std::forward<_Args>(__args)...);
425 return { __it, this };
426 }
427# endif
428
429 template <typename _Obj>
431 insert_or_assign(const key_type& __k, _Obj&& __obj)
432 {
433 auto __res = _Base::insert_or_assign(__k,
434 std::forward<_Obj>(__obj));
435 return { { __res.first, this }, __res.second };
436 }
437
438 template <typename _Obj>
440 insert_or_assign(key_type&& __k, _Obj&& __obj)
441 {
442 auto __res = _Base::insert_or_assign(std::move(__k),
443 std::forward<_Obj>(__obj));
444 return { { __res.first, this }, __res.second };
445 }
446
447# ifdef __glibcxx_associative_heterogeneous_insertion
448 template <__heterogeneous_tree_key<map> _Kt, typename _Obj>
450 insert_or_assign(_Kt&& __k, _Obj&& __obj)
451 {
452 auto __res = _Base::insert_or_assign(
454 return { { __res.first, this }, __res.second };
455 }
456#endif
457
458 template <typename _Obj>
460 insert_or_assign(const_iterator __hint,
461 const key_type& __k, _Obj&& __obj)
462 {
464 auto __it = _Base::insert_or_assign(__hint.base(), __k,
465 std::forward<_Obj>(__obj));
466 return { __it, this };
467 }
468
469 template <typename _Obj>
471 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
472 {
474 auto __it = _Base::insert_or_assign(__hint.base(), std::move(__k),
475 std::forward<_Obj>(__obj));
476 return { __it, this };
477 }
478
479# ifdef __glibcxx_associative_heterogeneous_insertion
480 template <__heterogeneous_tree_key<map> _Kt, typename _Obj>
482 insert_or_assign(const_iterator __hint, _Kt&& __k, _Obj&& __obj)
483 {
485 auto __it = _Base::insert_or_assign(__hint.base(),
487 return { __it, this };
488 }
489# endif
490
491#endif // C++17
492
493#ifdef __glibcxx_node_extract // >= C++17 && HOSTED
494 using node_type = typename _Base::node_type;
495 using insert_return_type = _Node_insert_return<iterator, node_type>;
496
497 node_type
498 extract(const_iterator __position)
499 {
500 __glibcxx_check_erase(__position);
501 this->_M_invalidate_if(_Equal(__position.base()));
502 return _Base::extract(__position.base());
503 }
504
505 node_type
506 extract(const key_type& __key)
507 {
508 const auto __position = find(__key);
509 if (__position != end())
510 return extract(__position);
511 return {};
512 }
513
514# ifdef __glibcxx_associative_heterogeneous_erasure
515 template <__heterogeneous_tree_key<map> _Kt>
516 node_type
517 extract(_Kt&& __key)
518 {
519 const auto __position = find(__key);
520 if (__position != end())
521 return extract(__position);
522 return {};
523 }
524# endif
525
526 insert_return_type
527 insert(node_type&& __nh)
528 {
529 auto __ret = _Base::insert(std::move(__nh));
530 return
531 { { __ret.position, this }, __ret.inserted, std::move(__ret.node) };
532 }
533
535 insert(const_iterator __hint, node_type&& __nh)
536 {
538 return { _Base::insert(__hint.base(), std::move(__nh)), this };
539 }
540
541 using _Base::merge;
542#endif // C++17
543
544#if __cplusplus >= 201103L
547 {
548 __glibcxx_check_erase(__position);
549 return { erase(__position.base()), this };
550 }
551
552 _Base_iterator
554 {
555 __glibcxx_check_erase2(__position);
556 this->_M_invalidate_if(_Equal(__position));
557 return _Base::erase(__position);
558 }
559
562 erase(iterator __position)
563 { return erase(const_iterator(__position)); }
564#else
565 void
566 erase(iterator __position)
567 {
568 __glibcxx_check_erase(__position);
569 this->_M_invalidate_if(_Equal(__position.base()));
570 _Base::erase(__position.base());
571 }
572#endif
573
575 erase(const key_type& __x)
576 {
577 _Base_iterator __victim = _Base::find(__x);
578 if (__victim == _Base::end())
579 return 0;
580 else
581 {
582 this->_M_invalidate_if(_Equal(__victim));
583 _Base::erase(__victim);
584 return 1;
585 }
586 }
587
588# ifdef __glibcxx_associative_heterogeneous_erasure
589 // Note that for some types _Kt this may erase more than
590 // one element, such as if _Kt::operator< checks only part
591 // of the key.
592 template <__heterogeneous_tree_key<map> _Kt>
594 erase(_Kt&& __x)
595 {
596 auto __victims = _Base::equal_range(__x);
597 size_type __count = 0;
598 for (auto __victim = __victims.first; __victim != __victims.second;)
599 {
600 this->_M_invalidate_if(_Equal(__victim));
601 _Base::erase(__victim++);
602 ++__count;
603 }
604 return __count;
605 }
606# endif
607
608#if __cplusplus >= 201103L
609 iterator
611 {
612 // _GLIBCXX_RESOLVE_LIB_DEFECTS
613 // 151. can't currently clear() empty container
614 __glibcxx_check_erase_range(__first, __last);
615 for (_Base_const_iterator __victim = __first.base();
616 __victim != __last.base(); ++__victim)
617 {
620 ._M_iterator(__first, "first")
621 ._M_iterator(__last, "last"));
622 this->_M_invalidate_if(_Equal(__victim));
623 }
624
625 return { _Base::erase(__first.base(), __last.base()), this };
626 }
627#else
628 void
629 erase(iterator __first, iterator __last)
630 {
631 // _GLIBCXX_RESOLVE_LIB_DEFECTS
632 // 151. can't currently clear() empty container
633 __glibcxx_check_erase_range(__first, __last);
634 for (_Base_iterator __victim = __first.base();
635 __victim != __last.base(); ++__victim)
636 {
637 _GLIBCXX_DEBUG_VERIFY(__victim != _Base::end(),
639 ._M_iterator(__first, "first")
640 ._M_iterator(__last, "last"));
641 this->_M_invalidate_if(_Equal(__victim));
642 }
643 _Base::erase(__first.base(), __last.base());
644 }
645#endif
646
647 void
648 swap(map& __x)
649 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
650 {
651 _Safe::_M_swap(__x);
652 _Base::swap(__x);
653 }
654
655 void
656 clear() _GLIBCXX_NOEXCEPT
657 {
658 this->_M_invalidate_all();
659 _Base::clear();
660 }
661
662 // observers:
663 using _Base::key_comp;
664 using _Base::value_comp;
665
666 // 23.3.1.3 map operations:
668 find(const key_type& __x)
669 { return iterator(_Base::find(__x), this); }
670
671#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
672 template<typename _Kt,
673 typename _Req =
676 find(const _Kt& __x)
677 { return { _Base::find(__x), this }; }
678#endif
679
680 const_iterator
681 find(const key_type& __x) const
682 { return const_iterator(_Base::find(__x), this); }
683
684#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
685 template<typename _Kt,
686 typename _Req =
688 const_iterator
689 find(const _Kt& __x) const
690 { return { _Base::find(__x), this }; }
691#endif
692
693 using _Base::count;
694
695 iterator
697 { return iterator(_Base::lower_bound(__x), this); }
698
699#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
700 template<typename _Kt,
701 typename _Req =
704 lower_bound(const _Kt& __x)
705 { return { _Base::lower_bound(__x), this }; }
706#endif
707
708 const_iterator
709 lower_bound(const key_type& __x) const
710 { return const_iterator(_Base::lower_bound(__x), this); }
711
712#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
713 template<typename _Kt,
714 typename _Req =
716 const_iterator
717 lower_bound(const _Kt& __x) const
718 { return { _Base::lower_bound(__x), this }; }
719#endif
720
721 iterator
723 { return iterator(_Base::upper_bound(__x), this); }
724
725#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
726 template<typename _Kt,
727 typename _Req =
730 upper_bound(const _Kt& __x)
731 { return { _Base::upper_bound(__x), this }; }
732#endif
733
734 const_iterator
735 upper_bound(const key_type& __x) const
736 { return const_iterator(_Base::upper_bound(__x), this); }
737
738#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
739 template<typename _Kt,
740 typename _Req =
742 const_iterator
743 upper_bound(const _Kt& __x) const
744 { return { _Base::upper_bound(__x), this }; }
745#endif
746
749 {
752 return std::make_pair(iterator(__res.first, this),
753 iterator(__res.second, this));
754 }
755
756#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
757 template<typename _Kt,
758 typename _Req =
761 equal_range(const _Kt& __x)
762 {
763 auto __res = _Base::equal_range(__x);
764 return { { __res.first, this }, { __res.second, this } };
765 }
766#endif
767
769 equal_range(const key_type& __x) const
770 {
773 return std::make_pair(const_iterator(__res.first, this),
774 const_iterator(__res.second, this));
775 }
776
777#ifdef __glibcxx_generic_associative_lookup // C++ >= 14
778 template<typename _Kt,
779 typename _Req =
782 equal_range(const _Kt& __x) const
783 {
784 auto __res = _Base::equal_range(__x);
785 return { { __res.first, this }, { __res.second, this } };
786 }
787#endif
788
789 _Base&
790 _M_base() _GLIBCXX_NOEXCEPT { return *this; }
791
792 const _Base&
793 _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
794 };
795
796#if __cpp_deduction_guides >= 201606
797
798 template<typename _InputIterator,
800 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
802 typename = _RequireNotAllocator<_Compare>,
803 typename = _RequireAllocator<_Allocator>>
804 map(_InputIterator, _InputIterator,
805 _Compare = _Compare(), _Allocator = _Allocator())
807 _Compare, _Allocator>;
808
809 template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
810 typename _Allocator = allocator<pair<const _Key, _Tp>>,
811 typename = _RequireNotAllocator<_Compare>,
812 typename = _RequireAllocator<_Allocator>>
814 _Compare = _Compare(), _Allocator = _Allocator())
816
817 template <typename _InputIterator, typename _Allocator,
819 typename = _RequireAllocator<_Allocator>>
820 map(_InputIterator, _InputIterator, _Allocator)
823
824 template<typename _Key, typename _Tp, typename _Allocator,
825 typename = _RequireAllocator<_Allocator>>
827 -> map<_Key, _Tp, less<_Key>, _Allocator>;
828
829#if __glibcxx_containers_ranges // C++ >= 23
830 template<ranges::input_range _Rg,
831 __not_allocator_like _Compare = less<__detail::__range_key_type<_Rg>>,
832 __allocator_like _Alloc =
834 map(from_range_t, _Rg&&, _Compare = _Compare(), _Alloc = _Alloc())
836 __detail::__range_mapped_type<_Rg>,
837 _Compare, _Alloc>;
838
839 template<ranges::input_range _Rg, __allocator_like _Alloc>
840 map(from_range_t, _Rg&&, _Alloc)
842 __detail::__range_mapped_type<_Rg>,
844 _Alloc>;
845#endif
846#endif // deduction guides
847
848 template<typename _Key, typename _Tp,
849 typename _Compare, typename _Allocator>
850 inline bool
853 { return __lhs._M_base() == __rhs._M_base(); }
854
855#if __cpp_lib_three_way_comparison
856 template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
857 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
860 { return __lhs._M_base() <=> __rhs._M_base(); }
861#else
862 template<typename _Key, typename _Tp,
863 typename _Compare, typename _Allocator>
864 inline bool
867 { return __lhs._M_base() != __rhs._M_base(); }
868
869 template<typename _Key, typename _Tp,
870 typename _Compare, typename _Allocator>
871 inline bool
874 { return __lhs._M_base() < __rhs._M_base(); }
875
876 template<typename _Key, typename _Tp,
877 typename _Compare, typename _Allocator>
878 inline bool
881 { return __lhs._M_base() <= __rhs._M_base(); }
882
883 template<typename _Key, typename _Tp,
884 typename _Compare, typename _Allocator>
885 inline bool
888 { return __lhs._M_base() >= __rhs._M_base(); }
889
890 template<typename _Key, typename _Tp,
891 typename _Compare, typename _Allocator>
892 inline bool
895 { return __lhs._M_base() > __rhs._M_base(); }
896#endif // three-way comparison
897
898 template<typename _Key, typename _Tp,
899 typename _Compare, typename _Allocator>
900 inline void
903 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
904 { __lhs.swap(__rhs); }
905
906} // namespace __debug
907} // namespace std
908
909#endif
#define _GLIBCXX_VISIBILITY(V)
#define __glibcxx_check_insert(_Position)
Definition macros.h:143
#define __glibcxx_check_valid_range2(_First, _Last, _Dist)
Definition macros.h:70
#define __glibcxx_check_erase2(_CPosition)
Definition macros.h:220
#define __glibcxx_check_erase_range(_First, _Last)
Definition macros.h:245
#define __glibcxx_check_erase(_Position)
Definition macros.h:209
#define _GLIBCXX_DEBUG_VERIFY(_Cond, _ErrMsg)
Definition macros.h:52
#define __glibcxx_check_valid_constructor_range(_First, _Last)
Definition macros.h:76
#define _GLIBCXX_ABI_TAG_CXX11
Definition c++config.h:168
pair(_T1, _T2) -> pair< _T1, _T2 >
Two pairs are equal iff their members are equal.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
Definition stl_pair.h:1166
auto declval() noexcept -> decltype(__declval< _Tp >(0))
Definition type_traits:2714
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Definition move.h:138
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Definition move.h:72
constexpr bool operator>(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator<(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator<=(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
constexpr bool operator>=(const reverse_iterator< _IteratorL > &__x, const reverse_iterator< _IteratorR > &__y)
__remove_cvref_t< typename iterator_traits< _InputIterator >::value_type::second_type > __iter_val_t
bool operator!=(const fpos< _StateT > &__lhs, const fpos< _StateT > &__rhs)
Definition postypes.h:202
__enable_if_t< is_convertible< __iter_category_t< _InIter >, input_iterator_tag >::value > _RequireInputIter
ISO C++ entities toplevel namespace is std.
constexpr _Iterator __unsafe(_Iterator __it)
@ __msg_valid_range
Definition formatter.h:108
GNU debug classes for public use.
void swap(map< _Key, _Tp, _Compare, _Allocator > &__lhs, map< _Key, _Tp, _Compare, _Allocator > &__rhs) noexcept(/*conditional */)
Definition map.h:901
__detail::__synth3way_t< pair< const _Key, _Tp > > operator<=>(const map< _Key, _Tp, _Compare, _Alloc > &__lhs, const map< _Key, _Tp, _Compare, _Alloc > &__rhs)
Definition map.h:858
map(_InputIterator, _InputIterator, _Compare=_Compare(), _Allocator=_Allocator()) -> map< __iter_key_t< _InputIterator >, __iter_val_t< _InputIterator >, _Compare, _Allocator >
bool operator==(const map< _Key, _Tp, _Compare, _Allocator > &__lhs, const map< _Key, _Tp, _Compare, _Allocator > &__rhs)
Definition map.h:851
GNU debug code, replaces standard behavior with debug behavior.
initializer_list
Define a member typedef type only if a boolean constant is true.
Definition type_traits:137
is_constructible
Definition type_traits:1238
The standard allocator, as per C++03 [20.4.1].
Definition allocator.h:134
constexpr _Iterator & base() noexcept
Return the underlying iterator.
Safe iterator wrapper.
One of the comparison functors.
_T1 first
The first member.
Definition stl_pair.h:308
_T2 second
The second member.
Definition stl_pair.h:309
Struct holding two objects of arbitrary type.
Definition stl_pair.h:304
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
Definition stl_map.h:107
void insert(std::initializer_list< value_type > __list)
Definition map.h:311
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Definition map.h:269
void insert(_InputIterator __first, _InputIterator __last)
Definition map.h:353
map(const allocator_type &__a)
Definition map.h:114
map(map &&__m, const __type_identity_t< allocator_type > &__a) noexcept(noexcept(_Base(std::move(__m), __a)))
Definition map.h:120
map & operator=(const map &)=default
const_iterator upper_bound(const key_type &__x) const
Definition map.h:735
std::reverse_iterator< iterator > reverse_iterator
Definition map.h:91
map(initializer_list< value_type > __l, const allocator_type &__a)
Definition map.h:125
std::pair< iterator, bool > insert(value_type &&__x)
Definition map.h:292
iterator upper_bound(const key_type &__x)
Definition map.h:722
_Base::reference reference
Definition map.h:79
_Base::size_type size_type
Definition map.h:87
const_reverse_iterator rbegin() const noexcept
Definition map.h:216
_Base_iterator erase(_Base_const_iterator __position)
Definition map.h:553
iterator insert(const_iterator __position, _Pair &&__x)
Definition map.h:340
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Definition map.h:129
_Base::const_reference const_reference
Definition map.h:80
iterator end() noexcept
Definition map.h:204
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Definition map.h:769
map(_Base_ref __x)
Definition map.h:158
const _Base & _M_base() const noexcept
Definition map.h:793
std::pair< iterator, bool > insert(const value_type &__x)
Definition map.h:281
_Compare key_compare
Definition map.h:77
map(const map &)=default
std::pair< const _Key, _Tp > value_type
Definition map.h:76
iterator begin() noexcept
Definition map.h:196
iterator find(const key_type &__x)
Definition map.h:668
const_iterator end() const noexcept
Definition map.h:208
iterator insert(const_iterator __position, value_type &&__x)
Definition map.h:330
const_iterator lower_bound(const key_type &__x) const
Definition map.h:709
_Allocator allocator_type
Definition map.h:78
const_iterator find(const key_type &__x) const
Definition map.h:681
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition map.h:92
__gnu_debug::_Safe_container< map, _Allocator, __gnu_debug::_Safe_node_sequence > _Safe
Definition map.h:53
reverse_iterator rbegin() noexcept
Definition map.h:212
const_iterator cend() const noexcept
Definition map.h:233
__gnu_debug::_Equal_to< _Base_const_iterator > _Equal
Definition map.h:57
const_iterator begin() const noexcept
Definition map.h:200
map & operator=(initializer_list< value_type > __l)
Definition map.h:182
__gnu_debug::_Safe_iterator< _Base_const_iterator, map > const_iterator
Definition map.h:85
map(const map &__m, const __type_identity_t< allocator_type > &__a)
Definition map.h:117
_Base::iterator _Base_iterator
Definition map.h:56
_Key key_type
Definition map.h:74
map(map &&)=default
void swap(map &__x) noexcept(/*conditional */)
Definition map.h:648
_Base::const_iterator _Base_const_iterator
Definition map.h:55
_Base::pointer pointer
Definition map.h:89
__gnu_debug::_Safe_iterator< _Base_iterator, map > iterator
Definition map.h:83
const_reverse_iterator crbegin() const noexcept
Definition map.h:237
const_reverse_iterator rend() const noexcept
Definition map.h:224
std::pair< iterator, bool > emplace(_Args &&... __args)
Definition map.h:261
_Base & _M_base() noexcept
Definition map.h:790
iterator lower_bound(const key_type &__x)
Definition map.h:696
std::pair< iterator, bool > insert(_Pair &&__x)
Definition map.h:302
const_iterator cbegin() const noexcept
Definition map.h:229
std::pair< iterator, iterator > equal_range(const key_type &__x)
Definition map.h:748
map(initializer_list< value_type > __l, const _Compare &__c=_Compare(), const allocator_type &__a=allocator_type())
Definition map.h:108
::map< _Key, _Tp, _Compare, _Allocator > _Base
Definition map.h:51
void clear() noexcept
Definition map.h:656
map & operator=(map &&)=default
iterator erase(const_iterator __position)
Definition map.h:546
map(const _Compare &__comp, const _Allocator &__a=_Allocator())
Definition map.h:161
_Base::difference_type difference_type
Definition map.h:88
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp=_Compare(), const _Allocator &__a=_Allocator())
Definition map.h:166
reverse_iterator rend() noexcept
Definition map.h:220
const_reverse_iterator crend() const noexcept
Definition map.h:241
_Base::const_pointer const_pointer
Definition map.h:90
size_type erase(const key_type &__x)
Definition map.h:575
iterator insert(const_iterator __position, const value_type &__x)
Definition map.h:317
_Tp mapped_type
Definition map.h:75
iterator erase(const_iterator __first, const_iterator __last)
Definition map.h:610
Class std::map with safety/checking/debug instrumentation.
Definition map.h:49
const _Base & _M_ref
Definition map.h:69
_Base_ref(const _Base &__r)
Definition map.h:67
constexpr void _M_swap(const _Safe_container &__x) const noexcept
Safe class dealing with some allocator dependent operations.
Like _Safe_sequence but with a special _M_invalidate_all implementation not invalidating past-the-end...
A range for which ranges::begin returns an input iterator.