61#if __cplusplus >= 201103L
66namespace std _GLIBCXX_VISIBILITY(default)
68_GLIBCXX_BEGIN_NAMESPACE_VERSION
69_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
71 template <
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
98 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
99 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
104 typedef _Tp mapped_type;
106 typedef _Compare key_compare;
107 typedef _Alloc allocator_type;
110#ifdef _GLIBCXX_CONCEPT_CHECKS
113# if __cplusplus < 201103L
114 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
116 __glibcxx_class_requires4(_Compare,
bool,
_Key,
_Key,
117 _BinaryFunctionConcept)
121#if __cplusplus >= 201103L
122#if __cplusplus > 201703L || defined __STRICT_ANSI__
124 "std::map must have the same value_type as its allocator");
129#pragma GCC diagnostic push
130#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
134 friend class map<
_Key, _Tp, _Compare, _Alloc>;
138 value_compare(_Compare __c)
143 {
return comp(__x.first,
__y.first); }
145#pragma GCC diagnostic pop
150 rebind<value_type>::other _Pair_alloc_type;
153 key_compare, _Pair_alloc_type> _Rep_type;
160#if __cplusplus >= 201703L
161 template<
typename _Up,
typename _Vp = remove_reference_t<_Up>>
162 static constexpr bool __usable_key
171 typedef typename _Alloc_traits::const_pointer const_pointer;
172 typedef typename _Alloc_traits::reference reference;
173 typedef typename _Alloc_traits::const_reference const_reference;
176 typedef typename _Rep_type::size_type size_type;
177 typedef typename _Rep_type::difference_type difference_type;
181#if __cplusplus > 201402L
192#if __cplusplus < 201103L
204 map(
const _Compare& __comp,
205 const allocator_type& __a = allocator_type())
206 : _M_t(__comp, _Pair_alloc_type(__a)) { }
213#if __cplusplus < 201103L
239 const _Compare& __comp = _Compare(),
240 const allocator_type& __a = allocator_type())
241 : _M_t(__comp, _Pair_alloc_type(__a))
242 { _M_t._M_insert_range_unique(
__l.begin(),
__l.end()); }
246 map(
const allocator_type& __a)
247 : _M_t(_Pair_alloc_type(__a)) { }
251 : _M_t(
__m._M_t, _Pair_alloc_type(__a)) { }
256 && _Alloc_traits::_S_always_equal())
257 : _M_t(
std::
move(
__m._M_t), _Pair_alloc_type(__a)) { }
261 : _M_t(_Pair_alloc_type(__a))
262 { _M_t._M_insert_range_unique(
__l.begin(),
__l.end()); }
265 template<
typename _InputIterator>
267 const allocator_type& __a)
268 : _M_t(_Pair_alloc_type(__a))
269 { _M_t._M_insert_range_unique(__first, __last); }
282 template<
typename _InputIterator>
285 { _M_t._M_insert_range_unique(__first, __last); }
299 template<
typename _InputIterator>
301 const _Compare& __comp,
302 const allocator_type& __a = allocator_type())
303 : _M_t(__comp, _Pair_alloc_type(__a))
304 { _M_t._M_insert_range_unique(__first, __last); }
306#if __cplusplus >= 201103L
320#if __cplusplus < 201103L
349 _M_t._M_assign_unique(
__l.begin(),
__l.end());
357 {
return allocator_type(_M_t.get_allocator()); }
367 {
return _M_t.begin(); }
376 {
return _M_t.begin(); }
385 {
return _M_t.end(); }
394 {
return _M_t.end(); }
403 {
return _M_t.rbegin(); }
410 const_reverse_iterator
412 {
return _M_t.rbegin(); }
421 {
return _M_t.rend(); }
428 const_reverse_iterator
430 {
return _M_t.rend(); }
432#if __cplusplus >= 201103L
440 {
return _M_t.begin(); }
449 {
return _M_t.end(); }
456 const_reverse_iterator
458 {
return _M_t.rbegin(); }
465 const_reverse_iterator
467 {
return _M_t.rend(); }
474 _GLIBCXX_NODISCARD
bool
476 {
return _M_t.empty(); }
481 {
return _M_t.size(); }
486 {
return _M_t.max_size(); }
510#if __cplusplus >= 201103L
517 return (*__i).second;
520#if __cplusplus >= 201103L
533 return (*__i).second;
551 __throw_out_of_range(__N(
"map::at"));
552 return (*__i).second;
556 at(
const key_type&
__k)
const
560 __throw_out_of_range(__N(
"map::at"));
561 return (*__i).second;
565#if __cplusplus >= 201103L
584 template<
typename... _Args>
588#if __cplusplus >= 201703L
589 if constexpr (
sizeof...(_Args) == 2)
593 if constexpr (__usable_key<
decltype(__a)>)
634 template<
typename...
_Args>
638 return _M_t._M_emplace_hint_unique(
__pos,
643#if __cplusplus > 201402L
649 return _M_t.extract(
__pos);
655 {
return _M_t.extract(__x); }
667 template<
typename,
typename>
668 friend struct std::_Rb_tree_merge_helper;
670 template<
typename _Cmp2>
675 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(
__source));
678 template<
typename _Cmp2>
680 merge(map<_Key, _Tp, _Cmp2, _Alloc>&& __source)
683 template<
typename _Cmp2>
685 merge(multimap<_Key, _Tp, _Cmp2, _Alloc>& __source)
687 using _Merge_helper = _Rb_tree_merge_helper<map, _Cmp2>;
688 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
691 template<
typename _Cmp2>
693 merge(multimap<_Key, _Tp, _Cmp2, _Alloc>&& __source)
697#if __cplusplus > 201402L
698#define __cpp_lib_map_try_emplace 201411L
719 template <
typename... _Args>
736 template <
typename...
_Args>
779 template <
typename... _Args>
798 template <
typename...
_Args>
834 {
return _M_t._M_insert_unique(__x); }
836#if __cplusplus >= 201103L
841 {
return _M_t._M_insert_unique(
std::move(__x)); }
843 template<
typename _Pair>
848#if __cplusplus >= 201703L
869#if __cplusplus >= 201103L
907#if __cplusplus >= 201103L
912 {
return _M_t._M_insert_unique_(
__position, __x); }
914#if __cplusplus >= 201103L
921 template<
typename _Pair>
925 return _M_t._M_emplace_hint_unique(
__position,
939 template<
typename _InputIterator>
942 { _M_t._M_insert_range_unique(__first, __last); }
944#if __cplusplus > 201402L
964 template <
typename _Obj>
982 template <
typename _Obj>
1019 template <
typename _Obj>
1040 template <
typename _Obj>
1054 __i = iterator(__true_hint.first);
1060#if __cplusplus >= 201103L
1083 _GLIBCXX_ABI_TAG_CXX11
1117 {
return _M_t.erase(__x); }
1119#if __cplusplus >= 201103L
1137 {
return _M_t.erase(__first, __last); }
1153 { _M_t.erase(__first, __last); }
1172 { _M_t.swap(__x._M_t); }
1191 {
return _M_t.key_comp(); }
1199 {
return value_compare(_M_t.key_comp()); }
1218 {
return _M_t.find(__x); }
1220#if __cplusplus > 201103L
1221 template<
typename _Kt>
1223 find(
const _Kt& __x) ->
decltype(_M_t._M_find_tr(__x))
1224 {
return _M_t._M_find_tr(__x); }
1243 {
return _M_t.find(__x); }
1245#if __cplusplus > 201103L
1246 template<
typename _Kt>
1248 find(
const _Kt& __x)
const ->
decltype(_M_t._M_find_tr(__x))
1249 {
return _M_t._M_find_tr(__x); }
1264 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
1266#if __cplusplus > 201103L
1267 template<
typename _Kt>
1269 count(
const _Kt& __x)
const ->
decltype(_M_t._M_count_tr(__x))
1270 {
return _M_t._M_count_tr(__x); }
1274#if __cplusplus > 201703L
1283 {
return _M_t.find(__x) != _M_t.end(); }
1285 template<
typename _Kt>
1288 ->
decltype(_M_t._M_find_tr(__x),
void(),
true)
1289 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
1307 {
return _M_t.lower_bound(__x); }
1309#if __cplusplus > 201103L
1310 template<
typename _Kt>
1313 ->
decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
1314 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
1332 {
return _M_t.lower_bound(__x); }
1334#if __cplusplus > 201103L
1335 template<
typename _Kt>
1352 {
return _M_t.upper_bound(__x); }
1354#if __cplusplus > 201103L
1355 template<
typename _Kt>
1358 ->
decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
1359 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
1372 {
return _M_t.upper_bound(__x); }
1374#if __cplusplus > 201103L
1375 template<
typename _Kt>
1401 {
return _M_t.equal_range(__x); }
1403#if __cplusplus > 201103L
1404 template<
typename _Kt>
1430 {
return _M_t.equal_range(__x); }
1432#if __cplusplus > 201103L
1433 template<
typename _Kt>
1437 _M_t._M_equal_range_tr(__x)))
1440 _M_t._M_equal_range_tr(__x));
1445 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1450#if __cpp_lib_three_way_comparison
1451 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1452 friend __detail::__synth3way_t<pair<const _K1, _T1>>
1456 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1464#if __cpp_deduction_guides >= 201606
1466 template<
typename _InputIterator,
1467 typename _Compare = less<__iter_key_t<_InputIterator>>,
1468 typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>,
1469 typename = _RequireInputIter<_InputIterator>,
1470 typename = _RequireNotAllocator<_Compare>,
1471 typename = _RequireAllocator<_Allocator>>
1472 map(_InputIterator, _InputIterator,
1473 _Compare = _Compare(), _Allocator = _Allocator())
1474 -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
1475 _Compare, _Allocator>;
1477 template<
typename _Key,
typename _Tp,
typename _Compare = less<_Key>,
1478 typename _Allocator = allocator<pair<const _Key, _Tp>>,
1479 typename = _RequireNotAllocator<_Compare>,
1480 typename = _RequireAllocator<_Allocator>>
1481 map(initializer_list<pair<_Key, _Tp>>,
1482 _Compare = _Compare(), _Allocator = _Allocator())
1483 -> map<_Key, _Tp, _Compare, _Allocator>;
1485 template <
typename _InputIterator,
typename _Allocator,
1486 typename = _RequireInputIter<_InputIterator>,
1487 typename = _RequireAllocator<_Allocator>>
1488 map(_InputIterator, _InputIterator, _Allocator)
1489 -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>,
1490 less<__iter_key_t<_InputIterator>>, _Allocator>;
1492 template<
typename _Key,
typename _Tp,
typename _Allocator,
1493 typename = _RequireAllocator<_Allocator>>
1494 map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1495 -> map<_Key, _Tp, less<_Key>, _Allocator>;
1509 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1513 {
return __x._M_t ==
__y._M_t; }
1515#if __cpp_lib_three_way_comparison
1530 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1531 inline __detail::__synth3way_t<pair<const _Key, _Tp>>
1532 operator<=>(
const map<_Key, _Tp, _Compare, _Alloc>& __x,
1533 const map<_Key, _Tp, _Compare, _Alloc>& __y)
1534 {
return __x._M_t <=> __y._M_t; }
1547 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1551 {
return __x._M_t <
__y._M_t; }
1554 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1558 {
return !(__x ==
__y); }
1561 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1565 {
return __y < __x; }
1568 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1572 {
return !(
__y < __x); }
1575 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1579 {
return !(__x <
__y); }
1583 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1590_GLIBCXX_END_NAMESPACE_CONTAINER
1592#if __cplusplus > 201402L
1594 template<
typename _Key,
typename _Val,
typename _Cmp1,
typename _Alloc,
1597 _Rb_tree_merge_helper<_GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>,
1601 friend class _GLIBCXX_STD_C::map<_Key, _Val, _Cmp1, _Alloc>;
1604 _S_get_tree(_GLIBCXX_STD_C::map<_Key, _Val, _Cmp2, _Alloc>& __map)
1605 {
return __map._M_t; }
1608 _S_get_tree(_GLIBCXX_STD_C::multimap<_Key, _Val, _Cmp2, _Alloc>& __map)
1609 {
return __map._M_t; }
1613_GLIBCXX_END_NAMESPACE_VERSION
constexpr tuple< _Elements &&... > forward_as_tuple(_Elements &&... __args) noexcept
std::forward_as_tuple
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr piecewise_construct_t piecewise_construct
Tag for piecewise construction of std::pair objects.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
Primary class template, tuple.
is_nothrow_copy_constructible
Struct holding two objects of arbitrary type.
A standard container made up of (key,value) pairs, which can be retrieved based on a key,...
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to build and insert a std::pair into the map.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
__enable_if_t< is_constructible< value_type, _Pair >::value, iterator > insert(const_iterator __position, _Pair &&__x)
Attempts to insert a std::pair into the map.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
auto equal_range(const _Kt &__x) const -> decltype(pair< const_iterator, const_iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
bool empty() const noexcept
const_reverse_iterator rend() const noexcept
bool contains(const key_type &__x) const
Finds whether an element with the given key exists.
map(const map &__m, const __type_identity_t< allocator_type > &__a)
Allocator-extended copy constructor.
value_compare value_comp() const
auto lower_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
pair< iterator, bool > try_emplace(const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the map.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
insert_return_type insert(node_type &&__nh)
Re-insert an extracted node.
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
iterator try_emplace(const_iterator __hint, const key_type &__k, _Args &&... __args)
Attempts to build and insert a std::pair into the map.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
map(map &&)=default
Map move constructor.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
const_reverse_iterator rbegin() const noexcept
reverse_iterator rbegin() noexcept
iterator insert_or_assign(const_iterator __hint, const key_type &__k, _Obj &&__obj)
Attempts to insert or assign a std::pair into the map.
const_iterator end() const noexcept
const_iterator cend() const noexcept
mapped_type & at(const key_type &__k)
Access to map data.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
key_compare key_comp() const
map(map &&__m, const __type_identity_t< allocator_type > &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
const_reverse_iterator crbegin() const noexcept
pair< iterator, bool > insert_or_assign(const key_type &__k, _Obj &&__obj)
Attempts to insert or assign a std::pair into the map.
void swap(map &__x) noexcept(/*conditional */)
Swaps data with another map.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
iterator insert(const_iterator __hint, node_type &&__nh)
Re-insert an extracted node.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
map(const map &)=default
Map copy constructor.
node_type extract(const_iterator __pos)
Extract a node.
map(const allocator_type &__a)
Allocator-extended default constructor.
node_type extract(const key_type &__x)
Extract a node.
iterator insert(const_iterator __position, value_type &&__x)
Attempts to insert a std::pair into the map.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
reverse_iterator rend() noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
map & operator=(const map &)=default
Map assignment operator.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
size_type size() const noexcept
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
auto upper_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
iterator find(const key_type &__x)
Tries to locate an element in a map.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
__enable_if_t< is_constructible< value_type, _Pair >::value, pair< iterator, bool > > insert(_Pair &&__x)
Attempts to insert a std::pair into the map.
iterator erase(const_iterator __position)
Erases an element from a map.
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
auto contains(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x), void(), true)
Finds whether an element with the given key exists.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
const_reverse_iterator crend() const noexcept
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(iterator __position)
Erases an element from a map.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert a std::pair into the map.
const_iterator cbegin() const noexcept
size_type max_size() const noexcept
const_iterator begin() const noexcept
iterator begin() noexcept
map & operator=(map &&)=default
Move assignment operator.
std::pair< iterator, bool > insert(value_type &&__x)
Attempts to insert a std::pair into the map.
map()=default
Default constructor creates no elements.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
Uniform interface to C++98 and C++11 allocators.