61#if __cplusplus >= 201103L
66namespace 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> > >
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)
126 {
return comp(__x.first,
__y.first); }
132 rebind<value_type>::other _Pair_alloc_type;
135 key_compare, _Pair_alloc_type> _Rep_type;
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;
151 typedef typename _Rep_type::size_type size_type;
174 map(
const _Compare& __comp,
175 const allocator_type& __a = allocator_type())
176 : _M_t(__comp, _Pair_alloc_type(__a)) { }
188#if __cplusplus >= 201103L
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)
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>
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>
258 { _M_t._M_insert_unique(__first, __last); }
272 template<
typename _InputIterator>
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(); }
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(); }
482#if __cplusplus >= 201103L
489 return (*__i).second;
492#if __cplusplus >= 201103L
503 std::forward_as_tuple(std::move(
__k)),
505 return (*__i).second;
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>
586 template<
typename...
_Args>
590 return _M_t._M_emplace_hint_unique(
__pos,
595#if __cplusplus > 201402L
596#define __cpp_lib_map_try_emplace 201411
617 template <
typename...
_Args>
625 std::forward_as_tuple(
__k),
626 std::forward_as_tuple(
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(
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(
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(
709 __i = iterator(__true_hint.first);
732 {
return _M_t._M_insert_unique(__x); }
734#if __cplusplus >= 201103L
735 template<
typename _Pair,
typename =
typename
737 _Pair&&>::value>::type>
743#if __cplusplus >= 201103L
780#if __cplusplus >= 201103L
785 {
return _M_t._M_insert_unique_(
__position, __x); }
787#if __cplusplus >= 201103L
788 template<
typename _Pair,
typename =
typename
790 _Pair&&>::value>::type>
805 template<
typename _InputIterator>
808 { _M_t._M_insert_unique(__first, __last); }
810#if __cplusplus > 201402L
811#define __cpp_lib_map_insertion 201411
831 template <
typename _Obj>
839 std::forward_as_tuple(
__k),
840 std::forward_as_tuple(
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(
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(
901 __i = iterator(__true_hint.first);
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(
921 __i = iterator(__true_hint.first);
927#if __cplusplus >= 201103L
948 _GLIBCXX_ABI_TAG_CXX11
964 erase(iterator __position)
965 { _M_t.erase(__position); }
981 {
return _M_t.erase(__x); }
983#if __cplusplus >= 201103L
1001 {
return _M_t.erase(__first, __last); }
1017 { _M_t.erase(__first, __last); }
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_count_tr(__x); }
1150 {
return _M_t.lower_bound(__x); }
1152#if __cplusplus > 201103L
1153 template<
typename _Kt>
1156 ->
decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
1157 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
1175 {
return _M_t.lower_bound(__x); }
1177#if __cplusplus > 201103L
1178 template<
typename _Kt>
1181 ->
decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
1182 {
return const_iterator(_M_t._M_lower_bound_tr(__x)); }
1195 {
return _M_t.upper_bound(__x); }
1197#if __cplusplus > 201103L
1198 template<
typename _Kt>
1201 ->
decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
1202 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
1215 {
return _M_t.upper_bound(__x); }
1217#if __cplusplus > 201103L
1218 template<
typename _Kt>
1221 ->
decltype(const_iterator(_M_t._M_upper_bound_tr(__x)))
1222 {
return const_iterator(_M_t._M_upper_bound_tr(__x)); }
1244 {
return _M_t.equal_range(__x); }
1246#if __cplusplus > 201103L
1247 template<
typename _Kt>
1273 {
return _M_t.equal_range(__x); }
1275#if __cplusplus > 201103L
1276 template<
typename _Kt>
1280 _M_t._M_equal_range_tr(__x)))
1283 _M_t._M_equal_range_tr(__x));
1288 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1290 operator==(
const map<_K1, _T1, _C1, _A1>&,
1291 const map<_K1, _T1, _C1, _A1>&);
1293 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
1295 operator<(
const map<_K1, _T1, _C1, _A1>&,
1296 const map<_K1, _T1, _C1, _A1>&);
1309 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1313 {
return __x._M_t ==
__y._M_t; }
1326 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1330 {
return __x._M_t <
__y._M_t; }
1333 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1337 {
return !(__x ==
__y); }
1340 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1344 {
return __y < __x; }
1347 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1351 {
return !(
__y < __x); }
1354 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1358 {
return !(__x <
__y); }
1361 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1368_GLIBCXX_END_NAMESPACE_CONTAINER
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
ISO C++ entities toplevel namespace is std.
Primary class template, tuple.
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.
bool empty() const noexcept
const_reverse_iterator rend() const noexcept
value_compare value_comp() const
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.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
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
const_iterator end() const noexcept
const_iterator cend() const noexcept
mapped_type & at(const key_type &__k)
Access to map data.
key_compare key_comp() const
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
const_reverse_iterator crbegin() const noexcept
map() noexcept(/*conditional */)
Default constructor creates no elements.
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.
map(const map &__x)
Map copy constructor.
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
map & operator=(const map &__x)
Map assignment operator.
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
map(const allocator_type &__a)
Allocator-extended default constructor.
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.
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.
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.
iterator erase(const_iterator __position)
Erases an element from a map.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
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.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
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.
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.