61 #if __cplusplus >= 201103L 66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
94 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
95 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
99 typedef _Key key_type;
100 typedef _Tp mapped_type;
102 typedef _Compare key_compare;
103 typedef _Alloc allocator_type;
107 typedef typename _Alloc::value_type _Alloc_value_type;
108 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
109 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
110 _BinaryFunctionConcept)
111 __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
117 friend class map<_Key, _Tp, _Compare, _Alloc>;
121 value_compare(_Compare __c)
125 bool operator()(
const value_type& __x,
const value_type& __y)
const 132 rebind<value_type>::other _Pair_alloc_type;
134 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
135 key_compare, _Pair_alloc_type> _Rep_type;
145 typedef typename _Alloc_traits::pointer pointer;
146 typedef typename _Alloc_traits::const_pointer const_pointer;
147 typedef typename _Alloc_traits::reference reference;
148 typedef typename _Alloc_traits::const_reference const_reference;
149 typedef typename _Rep_type::iterator iterator;
150 typedef typename _Rep_type::const_iterator const_iterator;
151 typedef typename _Rep_type::size_type size_type;
152 typedef typename _Rep_type::difference_type difference_type;
163 _GLIBCXX_NOEXCEPT_IF(
164 is_nothrow_default_constructible<allocator_type>::value
165 && is_nothrow_default_constructible<key_compare>::value)
174 map(
const _Compare& __comp,
175 const allocator_type& __a = allocator_type())
176 : _M_t(__comp, _Pair_alloc_type(__a)) { }
188 #if __cplusplus >= 201103L 197 noexcept(is_nothrow_copy_constructible<_Compare>::value)
198 : _M_t(
std::move(__x._M_t)) { }
212 const _Compare& __comp = _Compare(),
213 const allocator_type& __a = allocator_type())
214 : _M_t(__comp, _Pair_alloc_type(__a))
215 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
219 map(
const allocator_type& __a)
220 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
223 map(
const map& __m,
const allocator_type& __a)
224 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
227 map(
map&& __m,
const allocator_type& __a)
228 noexcept(is_nothrow_copy_constructible<_Compare>::value
229 && _Alloc_traits::_S_always_equal())
230 : _M_t(
std::move(__m._M_t), _Pair_alloc_type(__a)) { }
234 : _M_t(_Compare(), _Pair_alloc_type(__a))
235 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
238 template<
typename _InputIterator>
239 map(_InputIterator __first, _InputIterator __last,
240 const allocator_type& __a)
241 : _M_t(_Compare(), _Pair_alloc_type(__a))
242 { _M_t._M_insert_unique(__first, __last); }
255 template<
typename _InputIterator>
256 map(_InputIterator __first, _InputIterator __last)
258 { _M_t._M_insert_unique(__first, __last); }
272 template<
typename _InputIterator>
273 map(_InputIterator __first, _InputIterator __last,
274 const _Compare& __comp,
275 const allocator_type& __a = allocator_type())
276 : _M_t(__comp, _Pair_alloc_type(__a))
277 { _M_t._M_insert_unique(__first, __last); }
302 #if __cplusplus >= 201103L 321 _M_t._M_assign_unique(__l.begin(), __l.end());
329 {
return allocator_type(_M_t.get_allocator()); }
339 {
return _M_t.begin(); }
348 {
return _M_t.begin(); }
357 {
return _M_t.end(); }
365 end() const _GLIBCXX_NOEXCEPT
366 {
return _M_t.end(); }
375 {
return _M_t.rbegin(); }
382 const_reverse_iterator
384 {
return _M_t.rbegin(); }
393 {
return _M_t.rend(); }
400 const_reverse_iterator
402 {
return _M_t.rend(); }
404 #if __cplusplus >= 201103L 412 {
return _M_t.begin(); }
421 {
return _M_t.end(); }
428 const_reverse_iterator
430 {
return _M_t.rbegin(); }
437 const_reverse_iterator
439 {
return _M_t.rend(); }
448 {
return _M_t.empty(); }
453 {
return _M_t.size(); }
458 {
return _M_t.max_size(); }
477 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
482 #if __cplusplus >= 201103L 487 __i =
insert(__i, value_type(__k, mapped_type()));
489 return (*__i).second;
492 #if __cplusplus >= 201103L 497 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
503 std::forward_as_tuple(
std::move(__k)),
505 return (*__i).second;
519 at(
const key_type& __k)
523 __throw_out_of_range(__N(
"map::at"));
524 return (*__i).second;
528 at(
const key_type& __k)
const 532 __throw_out_of_range(__N(
"map::at"));
533 return (*__i).second;
537 #if __cplusplus >= 201103L 556 template<
typename... _Args>
559 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
586 template<
typename... _Args>
590 return _M_t._M_emplace_hint_unique(__pos,
591 std::forward<_Args>(__args)...);
595 #if __cplusplus > 201402L 596 #define __cpp_lib_map_try_emplace 201411 617 template <
typename... _Args>
619 try_emplace(
const key_type& __k, _Args&&... __args)
625 std::forward_as_tuple(__k),
626 std::forward_as_tuple(
627 std::forward<_Args>(__args)...));
634 template <
typename... _Args>
636 try_emplace(key_type&& __k, _Args&&... __args)
642 std::forward_as_tuple(std::move(__k)),
643 std::forward_as_tuple(
644 std::forward<_Args>(__args)...));
677 template <
typename... _Args>
679 try_emplace(const_iterator __hint,
const key_type& __k,
683 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
684 if (__true_hint.second)
687 std::forward_as_tuple(__k),
688 std::forward_as_tuple(
689 std::forward<_Args>(__args)...));
691 __i = iterator(__true_hint.first);
696 template <
typename... _Args>
698 try_emplace(const_iterator __hint, key_type&& __k, _Args&&... __args)
701 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
702 if (__true_hint.second)
705 std::forward_as_tuple(std::move(__k)),
706 std::forward_as_tuple(
707 std::forward<_Args>(__args)...));
709 __i = iterator(__true_hint.first);
732 {
return _M_t._M_insert_unique(__x); }
734 #if __cplusplus >= 201103L 735 template<
typename _Pair,
typename =
typename 736 std::enable_if<std::is_constructible<value_type,
737 _Pair&&>::value>::type>
740 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
743 #if __cplusplus >= 201103L 753 {
insert(__list.begin(), __list.end()); }
780 #if __cplusplus >= 201103L 781 insert(const_iterator __position,
const value_type& __x)
783 insert(iterator __position,
const value_type& __x)
785 {
return _M_t._M_insert_unique_(__position, __x); }
787 #if __cplusplus >= 201103L 788 template<
typename _Pair,
typename =
typename 789 std::enable_if<std::is_constructible<value_type,
790 _Pair&&>::value>::type>
792 insert(const_iterator __position, _Pair&& __x)
793 {
return _M_t._M_insert_unique_(__position,
794 std::forward<_Pair>(__x)); }
805 template<
typename _InputIterator>
807 insert(_InputIterator __first, _InputIterator __last)
808 { _M_t._M_insert_unique(__first, __last); }
810 #if __cplusplus > 201402L 811 #define __cpp_lib_map_insertion 201411 831 template <
typename _Obj>
833 insert_or_assign(
const key_type& __k, _Obj&& __obj)
839 std::forward_as_tuple(__k),
840 std::forward_as_tuple(
841 std::forward<_Obj>(__obj)));
844 (*__i).second = std::forward<_Obj>(__obj);
849 template <
typename _Obj>
851 insert_or_assign(key_type&& __k, _Obj&& __obj)
857 std::forward_as_tuple(std::move(__k)),
858 std::forward_as_tuple(
859 std::forward<_Obj>(__obj)));
862 (*__i).second = std::forward<_Obj>(__obj);
886 template <
typename _Obj>
888 insert_or_assign(const_iterator __hint,
889 const key_type& __k, _Obj&& __obj)
892 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
893 if (__true_hint.second)
897 std::forward_as_tuple(__k),
898 std::forward_as_tuple(
899 std::forward<_Obj>(__obj)));
901 __i = iterator(__true_hint.first);
902 (*__i).second = std::forward<_Obj>(__obj);
907 template <
typename _Obj>
909 insert_or_assign(const_iterator __hint, key_type&& __k, _Obj&& __obj)
912 auto __true_hint = _M_t._M_get_insert_hint_unique_pos(__hint, __k);
913 if (__true_hint.second)
917 std::forward_as_tuple(std::move(__k)),
918 std::forward_as_tuple(
919 std::forward<_Obj>(__obj)));
921 __i = iterator(__true_hint.first);
922 (*__i).second = std::forward<_Obj>(__obj);
927 #if __cplusplus >= 201103L 945 {
return _M_t.erase(__position); }
948 _GLIBCXX_ABI_TAG_CXX11
950 erase(iterator __position)
951 {
return _M_t.erase(__position); }
964 erase(iterator __position)
965 { _M_t.erase(__position); }
981 {
return _M_t.erase(__x); }
983 #if __cplusplus >= 201103L 1000 erase(const_iterator __first, const_iterator __last)
1001 {
return _M_t.erase(__first, __last); }
1016 erase(iterator __first, iterator __last)
1017 { _M_t.erase(__first, __last); }
1033 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
1034 { _M_t.swap(__x._M_t); }
1053 {
return _M_t.key_comp(); }
1061 {
return value_compare(_M_t.key_comp()); }
1080 {
return _M_t.find(__x); }
1082 #if __cplusplus > 201103L 1083 template<
typename _Kt>
1085 find(
const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
1086 {
return _M_t._M_find_tr(__x); }
1105 {
return _M_t.find(__x); }
1107 #if __cplusplus > 201103L 1108 template<
typename _Kt>
1110 find(
const _Kt& __x)
const -> decltype(_M_t._M_find_tr(__x))
1111 {
return _M_t._M_find_tr(__x); }
1126 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
1128 #if __cplusplus > 201103L 1129 template<
typename _Kt>
1131 count(
const _Kt& __x)
const -> decltype(_M_t._M_count_tr(__x))
1132 {
return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; }
1150 {
return _M_t.lower_bound(__x); }
1152 #if __cplusplus > 201103L 1153 template<
typename _Kt>
1156 -> decltype(_M_t._M_lower_bound_tr(__x))
1157 {
return _M_t._M_lower_bound_tr(__x); }
1175 {
return _M_t.lower_bound(__x); }
1177 #if __cplusplus > 201103L 1178 template<
typename _Kt>
1181 -> decltype(_M_t._M_lower_bound_tr(__x))
1182 {
return _M_t._M_lower_bound_tr(__x); }
1195 {
return _M_t.upper_bound(__x); }
1197 #if __cplusplus > 201103L 1198 template<
typename _Kt>
1201 -> decltype(_M_t._M_upper_bound_tr(__x))
1202 {
return _M_t._M_upper_bound_tr(__x); }
1215 {
return _M_t.upper_bound(__x); }
1217 #if __cplusplus > 201103L 1218 template<
typename _Kt>
1221 -> decltype(_M_t._M_upper_bound_tr(__x))
1222 {
return _M_t._M_upper_bound_tr(__x); }
1244 {
return _M_t.equal_range(__x); }
1246 #if __cplusplus > 201103L 1247 template<
typename _Kt>
1250 -> decltype(_M_t._M_equal_range_tr(__x))
1251 {
return _M_t._M_equal_range_tr(__x); }
1273 {
return _M_t.equal_range(__x); }
1275 #if __cplusplus > 201103L 1276 template<
typename _Kt>
1279 -> decltype(_M_t._M_equal_range_tr(__x))
1280 {
return _M_t._M_equal_range_tr(__x); }
1284 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1289 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1291 operator<(const map<_K1, _T1, _C1, _A1>&,
1305 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1309 {
return __x._M_t == __y._M_t; }
1322 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1324 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1326 {
return __x._M_t < __y._M_t; }
1329 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1333 {
return !(__x == __y); }
1336 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1340 {
return __y < __x; }
1343 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1345 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1347 {
return !(__y < __x); }
1350 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1354 {
return !(__x < __y); }
1357 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1361 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1364 _GLIBCXX_END_NAMESPACE_CONTAINER
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
const_reverse_iterator rend() const noexcept
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
bool operator>(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
key_compare key_comp() const
iterator erase(const_iterator __position)
Erases an element from a map.
bool empty() const noexcept
Uniform interface to C++98 and C++11 allocators.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
auto upper_bound(const _Kt &__x) const -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
const_reverse_iterator crend() const noexcept
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
Primary class template, tuple.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
size_type size() const noexcept
_T1 first
second_type is the second bound type
size_type erase(const key_type &__x)
Erases elements according to the provided key.
auto find(const _Kt &__x) -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
const_iterator cbegin() const noexcept
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
map() noexcept(/*conditional */)
Default constructor creates no elements.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements with given key.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
map(const allocator_type &__a)
Allocator-extended default constructor.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
map(const map &__x)
Map copy constructor.
value_compare value_comp() const
Struct holding two objects of arbitrary type.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
size_type max_size() const noexcept
bool operator>=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator<.
const_reverse_iterator crbegin() const noexcept
const_iterator begin() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.
map & operator=(const map &__x)
Map assignment operator.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
auto find(const _Kt &__x) const -> decltype(_M_t._M_find_tr(__x))
Tries to locate an element in a map.
reverse_iterator rbegin() noexcept
reverse_iterator rend() noexcept
iterator find(const key_type &__x)
Tries to locate an element in a map.
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
void swap(map &__x) noexcept(/*conditional */)
Swaps data with another map.
auto upper_bound(const _Kt &__x) -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
mapped_type & at(const key_type &__k)
Access to map data.
auto lower_bound(const _Kt &__x) const -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
ISO C++ entities toplevel namespace is std.
const_iterator cend() const noexcept
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
iterator begin() noexcept
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.