STD::MAP(3)
π NAME π
okay so real talk: this page lives in the Library Functions Manual, section 3, and it's all about std::map< ...e, _Alloc >. π
Bestie, std::map< _Key, _Tp, _Compare, _Alloc > is a standard container made up of (key,value) pairs, which can be retrieved based on a key, in logarithmic time. That's it, that's the whole vibe β you put stuff in, you look it up by key, and the lookup is logarithmic. β¨
π¦ SYNOPSIS π¦
#include <map>
π Public Types π
typedef _Alloc allocator_typetypedef _Rep_type::const_iterator const_iteratortypedef _Alloc_traits::const_pointer const_pointertypedef _Alloc_traits::const_reference const_referencetypedef _Rep_type::const_reverse_iterator const_reverse_iteratortypedef _Rep_type::difference_type difference_typetypedef _Rep_type::iterator iteratortypedef _Compare key_comparetypedef _Key key_typetypedef _Tp mapped_typetypedef _Alloc_traits::pointer pointertypedef _Alloc_traits::reference referencetypedef _Rep_type::reverse_iterator reverse_iteratortypedef _Rep_type::size_type size_typetypedef std::pair< const _Key, _Tp > value_type
β¨ Public Member Functions β¨
heads up bestie: this is the long part. Every single one is here, no skips, no cap. π«Ά
map ()=defaultβ default constructor, creates no elements. It's giving empty πtemplate<typename _InputIterator> map (_InputIterator __first, _InputIterator __last)β builds a map from a range.template<typename _InputIterator> map (_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())β builds a map from a range.template<typename _InputIterator> map (_InputIterator __first, _InputIterator __last, const allocator_type &__a)β allocator-extended range constructor.map (const _Compare &__comp, const allocator_type &__a=allocator_type())β creates a map with no elements.map (const allocator_type &__a)β allocator-extended default constructor.map (const map &)=defaultβ map copy constructor. twin energy π―map (const map &__m, const __type_identity_t< allocator_type > &__a)β allocator-extended copy constructor.map (initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())β builds a map from an initializer_list.map (initializer_list< value_type > __l, const allocator_type &__a)β allocator-extended initialier-list constructor.map (map &&)=defaultβ map move constructor. βοΈ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.~map ()=defaultβ destructor. bye bestie π«Άtemplate<__heterogeneous_tree_key< map > _Kt> mapped_type & at (const _Kt &__k)template<__heterogeneous_tree_key< map > _Kt> const mapped_type & at (const _Kt &__k) constmapped_type & at (const key_type &__k)β access to map data.const mapped_type & at (const key_type &__k) constconst_iterator begin () const noexceptiterator begin () noexceptconst_iterator cbegin () const noexceptconst_iterator cend () const noexceptvoid clear () noexceptconst_reverse_iterator crbegin () const noexceptconst_reverse_iterator crend () const noexcepttemplate<typename... _Args> std::pair< iterator, bool > emplace (_Args &&... __args)β attempts to build and insert a std::pair into the map.template<typename... _Args> iterator emplace_hint (const_iterator __pos, _Args &&... __args)β attempts to build and insert a std::pair into the map.bool empty () const noexceptconst_iterator end () const noexceptiterator end () noexceptiterator erase (const_iterator __first, const_iterator __last)β erases a[first,last)range of elements from a map.allocator_type get_allocator () const noexceptβ get a copy of the memory allocation object.template<typename _InputIterator> void insert (_InputIterator __first, _InputIterator __last)β template function that attempts to insert a range of elements.void insert (std::initializer_list< value_type > __list)β attempts to insert a list ofstd::pairs into the map.key_compare key_comp () constsize_type max_size () const noexceptmap & operator= (const map &)=defaultβ map assignment operator.map & operator= (initializer_list< value_type > __l)β map list assignment operator.map & operator= (map &&)=defaultβ move assignment operator.template<__heterogeneous_tree_key< map > _Kt> mapped_type & operator[] (_Kt &&__k)mapped_type & operator[] (const key_type &__k)β subscript ([]) access to map data.mapped_type & operator[] (key_type &&__k)const_reverse_iterator rbegin () const noexceptreverse_iterator rbegin () noexceptconst_reverse_iterator rend () const noexceptreverse_iterator rend () noexceptsize_type size () const noexceptvoid swap (map &__x) noexcept(/*conditional */)β swaps data with another map.value_compare value_comp () const
π the overloaded besties π
these ones hang out in their own little group, same descriptions as above, all listed, all accounted for:
std::pair< iterator, bool > insert (const value_type &__x)β attempts to insert a std::pair into the map.std::pair< iterator, bool > insert (value_type &&__x)β attempts to insert a std::pair into the map.template<typename _Pair> __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 insert (const_iterator __position, const value_type &__x)β attempts to insert a std::pair into the map.iterator insert (const_iterator __position, value_type &&__x)β attempts to insert a std::pair into the map.template<typename _Pair> __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.iterator erase (const_iterator __position)β erases an element from a map.iterator erase (iterator __position)β erases an element from a map.size_type erase (const key_type &__x)β erases elements according to the provided key.template<__heterogeneous_tree_key< map > _Kt> size_type erase (_Kt &&__x)β erases elements according to the provided key.iterator find (const key_type &__x)β tries to locate an element in a map.const_iterator find (const key_type &__x) constβ tries to locate an element in a map.size_type count (const key_type &__x) constβ finds the number of elements with given key.bool contains (const key_type &__x) constβ finds whether an element with the given key exists.template<typename _Kt> 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_iterator lower_bound (const key_type &__x) constβ finds the beginning of a subsequence matching given key.iterator upper_bound (const key_type &__x)β finds the end of a subsequence matching given key.const_iterator upper_bound (const key_type &__x) constβ 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.std::pair< const_iterator, const_iterator > equal_range (const key_type &__x) constβ finds a subsequence matching given key.
π Friends π
template<typename _K1, typename _T1, typename _C1, typename _A1> __detail::__synth3way_t< pair< const _K1, _T1 > > operator<=> (const map< _K1, _T1, _C1, _A1 > &, const map< _K1, _T1, _C1, _A1 > &)template<typename _K1, typename _T1, typename _C1, typename _A1> bool operator== (const map< _K1, _T1, _C1, _A1 > &, const map< _K1, _T1, _C1, _A1 > &)
π Detailed Description π
the whole class, in its full glory, exactly as declared:
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
class std::map< _Key, _Tp, _Compare, _Alloc >
"A standard container made up of (key,value) pairs, which can be retrieved based on a key, in logarithmic time."
π Since π
C++98β yes bestie, it's been iconic since 1998 π
π§ Template Parameters π§
_Keyβ type of key objects._Tpβ type of mapped objects._Compareβ comparison function object type, defaults toless<_Key>._Allocβ allocator type, defaults toallocator<pair<const _Key, _Tp>.
okay so more facts, keep up bestie:
Meets the requirements of a container, a reversible container, and an associative container (using unique keys). For a map<Key,T> the key_type is Key, the mapped_type is T, and the value_type is std::pair<const Key,T>. β¨
Maps support bidirectional iterators. π¦
The private tree data is declared exactly the same way for map and multimap; the distinction is made entirely in how the tree functions are called (*_unique versus *_equal, same as the standard). π
and we are SO not done, bestie β there's more of this page coming. don't go anywhere. π
π CONSTRUCTOR & DESTRUCTOR DOCUMENTATION π
okay bestie, this is the part where we learn how to make a map π every single one of these is a way to birth a map, and there are SO many. Don't panic. We go one at a time.
πΈ map () β the default constructor
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map () [default]
Default constructor creates no elements. That's it. Empty map, zero thoughts, no notes. It's giving "just woke up, nothing scheduled" energy. β¨
π¦ map (const _Compare & __comp, const allocator_type & __a = allocator_type())
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (const _Compare & __comp,
const allocator_type & __a = allocator_type()) [inline], [explicit]
Creates a map with no elements β but this time you get to hand it a comparison object and an allocator. Empty map, but customised. She's empty but she has β¨opinionsβ¨.
Parameters
__compβ A comparison object.__aβ An allocator object.
Heads up: this one is marked [explicit], so no sneaky implicit conversions, bestie. π«Ά
π map (const map< _Key, _Tp, _Compare, _Alloc > & ) β copy constructor
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (const map< _Key, _Tp, _Compare,
_Alloc > & ) [default]
Map copy constructor. Whether the allocator is copied depends on the allocator traits β so don't assume, it literally depends on the traits. allocator_traits said "it depends" and meant it. π
π§ map (map< _Key, _Tp, _Compare, _Alloc > && ) β move constructor
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (map< _Key, _Tp, _Compare, _Alloc >
&& ) [default]
Map move constructor. The newly-created map contains the exact contents of the moved instance. The moved instance is a valid, but unspecified, map β so it's alive but it's not okay, it's just valid. Think of it as "she left the group chat but she's still technically in it." π
π map (initializer_list< value_type > __l, const _Compare & __comp = _Compare(), const allocator_type & __a = allocator_type())
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (initializer_list< value_type > __l,
const _Compare & __comp = _Compare(), const allocator_type & __a =
allocator_type()) [inline]
Builds a map from an initializer_list. The curly-brace baddie. π₯
Parameters
__lβ Aninitializer_list.__compβ A comparison object.__aβ An allocator object.
Create a map consisting of copies of the elements in the initializer_list __l. This is linear in N if the range is already sorted, and NlogN otherwise (where N is __l.size()). Sorting already done = free speed. Slay. β
π map (const allocator_type & __a)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (const allocator_type & __a)
[inline], [explicit]
Allocator-extended default constructor. Empty map, but it brought its own allocator. Fancy empty. π
Also [explicit], so no implicit nonsense, we stan. π«Ά
π map (const map< _Key, _Tp, _Compare, _Alloc > & __m, const __type_identity_t< allocator_type > & __a)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (const map< _Key, _Tp, _Compare,
_Alloc > & __m, const __type_identity_t< allocator_type > & __a)
[inline]
Allocator-extended copy constructor. Same copy energy as before, but you're handing her the allocator yourself. __type_identity_t is there doing its little job of keeping the deduction honest. iykyk β¨
π¦ map (map< _Key, _Tp, _Compare, _Alloc > && __m, const __type_identity_t< allocator_type > & __a)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (map< _Key, _Tp, _Compare, _Alloc >
&& __m, const __type_identity_t< allocator_type > & __a) [inline],
[noexcept]
Allocator-extended move constructor. And it's noexcept β the rare and beautiful no-throw move. No cap, this is the good one. π
πΈ map (initializer_list< value_type > __l, const allocator_type & __a)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::map (initializer_list< value_type > __l,
const allocator_type & __a) [inline]
Allocator-extended initializer-list constructor. Curly braces + your own allocator = a match made in heaven. π
π§ map (_InputIterator __first, _InputIterator __last, const allocator_type & __a)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _InputIterator>
std::map< _Key, _Tp, _Compare, _Alloc >::map (_InputIterator __first,
_InputIterator __last, const allocator_type & __a) [inline]
Allocator-extended range constructor. Yeah it's a template template situation, she's nested, she's doing the most, and she's valid. Main character template energy. π
π map (_InputIterator __first, _InputIterator __last)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _InputIterator>
std::map< _Key, _Tp, _Compare, _Alloc >::map (_InputIterator __first,
_InputIterator __last) [inline]
Builds a map from a range. π«Ά
Parameters
__firstβ An input iterator.__lastβ An input iterator.
Create a map consisting of copies of the elements from [__first,__last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(__first,__last)).
Note the range is half-open β__firstin,__lastout. Don't be out here including__last, bestie. π
π map (_InputIterator __first, _InputIterator __last, const _Compare & __comp, const allocator_type & __a = allocator_type())
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _InputIterator>
std::map< _Key, _Tp, _Compare, _Alloc >::map (_InputIterator __first,
_InputIterator __last, const _Compare & __comp, const allocator_type & __a =
allocator_type()) [inline]
Builds a map from a range β but now with a comparison functor in the mix. Range and vibes. π₯
Parameters
__firstβ An input iterator.__lastβ An input iterator.__compβ A comparison functor.__aβ An allocator object.
Create a map consisting of copies of the elements from [__first,__last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(__first,__last)).
π ~map () β the destructor
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::map< _Key, _Tp, _Compare, _Alloc >::~map () [default]
The dtor only erases the elements, and note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
π¨ THIS IS THE IMPORTANT ONE. The destructor does not delete what your pointers point at. It deletes the pointer values sitting in the map, not the things they point to. If you new'd it, you own it. Clean it up yourself or you're leaking. Not a vibe. π
π MEMBER FUNCTION DOCUMENTATION π
okay so now the map is born and we get to do stuff with it. Here's every member function, no skips, no cuts. β¨
πΈ at (const key_type & __k)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
mapped_type & std::map< _Key, _Tp, _Compare, _Alloc >::at (const key_type & __k)
[inline]
Access to map data. Gimme the value at this key, right now, no debate. π
Parameters
__kβ The key for which data should be retrieved.
Returns
A reference to the data whose key is equivalent to __k, if such a data is present in the map.
Exceptions
std::out_of_range β If no such data is present.
If a heterogeneous key __k matches a range of elements, the first is chosen.
She THROWS if the key isn't there.atdoes not play. If you want "idk make one up," that'soperator[]'s whole personality (covered elsewhere, bestie). π«Ά
π¦ begin () const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::begin () const
[inline], [noexcept]
Returns a read-only (constant) iterator that points to the first pair in the map. Iteration is done in ascending order according to the keys. β¨
π begin ()
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::begin () [inline], [noexcept]
Returns a read/write iterator that points to the first pair in the map. Iteration is done in ascending order according to the keys.
Same as above but you can actually edit through this one. Read/write. Handle with care, bestie. π«Ά
π cbegin () const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::cbegin () const
[inline], [noexcept]
Returns a read-only (constant) iterator that points to the first pair in the map. Iteration is done in ascending order according to the keys. It's begin() const's twin, always const, always chill. π
π¦ cend () const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::cend () const
[inline], [noexcept]
Returns a read-only (constant) iterator that points one past the last pair in the map. Iteration is done in ascending order according to the keys. Classic end sentinel behaviour β you never dereference this one. Never. π
π clear ()
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> void
std::map< _Key, _Tp, _Compare, _Alloc >::clear () [inline], [noexcept]
Erases all elements in a map. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
π¨ Same warning as the destructor, bestie, and it matters just as much: clear() does not free what your pointers point at. Pointers gone, pointees still there, memory still leaked. You own it. π
π§ contains (const _Kt & __x) const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _Kt>
auto std::map< _Key, _Tp, _Compare, _Alloc >::contains (const _Kt & __x) const
-> decltype(_M_t._M_find_tr(__x), void(), true) [inline]
Finds whether an element with the given key exists. The heterogeneous-key version β you can ask with a type that isn't literally key_type. Look at that trailing return type doing gymnastics. Ate. π₯
Parameters
__xβ Key of (key, value) pairs to be located.
Returns
True if there is an element with the specified key.
π contains (const key_type & __x) const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> bool
std::map< _Key, _Tp, _Compare, _Alloc >::contains (const key_type & __x) const
[inline]
Finds whether an element with the given key exists. Same question, boring-old-key_type edition. Returns a plain bool instead of that fancy decltype business. π
Parameters
__xβ Key of (key, value) pairs to be located.
Returns
True if there is an element with the specified key.
πΈ count (const key_type & __x) const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> size_type
std::map< _Key, _Tp, _Compare, _Alloc >::count (const key_type & __x) const
[inline]
Finds the number of elements with given key. She's out here counting. π
Parameters
__xβ Key of (key, value) pairs to be located.
Returns
Number of elements with specified key.
This function only makes sense for multimaps; for map the result will either be 0 (not present) or 1 (present).
Real talk: on amapthis is basically a fanciercontains. She really shines on amultimap, where the answer can be more than 1. Bestie, know which container you're in. π«Ά
π¦ crbegin () const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::crbegin () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points to the last pair in the map. Iteration is done in descending order according to the keys. Walking backwards, but make it const. π
π crend () const
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::crend () const
[inline], [noexcept]
Returns a read-only (constant) reverse iterator that points one before the first pair in the map. Iteration is done in descending order according to the keys. The reverse-world sentinel. Don't touch. π
π emplace (_Args &&... __args)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename... _Args>
std::pair< iterator, bool > std::map< _Key, _Tp, _Compare, _Alloc >::emplace
(_Args &&... __args) [inline]
Attempts to build and insert a std::pair into the map. Builds it in place, no extra copy, we love efficiency in this house. β¨
Parameters
__argsβ Arguments used to generate a new pair instance (seestd::piecewise_contructfor passing arguments to each part of the pair constructor).
Returns
A pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is a bool that is true if the pair was actually inserted.
Note the word "attempts" β if the key was already chilling in the map, nothing gets inserted and thatboolcomes backfalse, with the iterator pointing at the existing element. Not a failure, just a "she's already here." π
So this function is out here trying to build and insert a (key, value) pair straight into the map. But bestie, a map only does unique keys β so a pair only actually gets inserted if its first element (the key) isn't already chilling in the map. β¨
Insertion requires logarithmic time, periodt.
emplace_hint() β the hint-hint girlie π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename... _Args> iterator std::map< _Key, _Tp, _Compare,
_Alloc >::emplace_hint (const_iterator __pos, _Args &&... __args)
[inline]
Attempts to build and insert a std::pair into the map. lowkey iconic.
Parameters
__posβ an iterator that's basically whispering a hint about where the pair should go.__argsβ the arguments used to generate a new pair instance (peepstd::piecewise_contructif you wanna pass arguments to each part of the pair constructor separately).
Returns
An iterator pointing at the element whose key comes from the std::pair built out of __args β and yeah, it may or may not be that exact std::pair, we don't gatekeep.
This function does not care whether the insertion actually happened, so no boolean coming back like the single-argument emplace() gives you. Also note: that first parameter is only a hint, and it can potentially boost insertion performance. A bad hint? Zero gains, bestie. Nothing. π
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting, iykyk.
Insertion requires logarithmic time (if the hint is not taken).
Referenced by std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::emplace(), and std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert().
empty() π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> bool
std::map< _Key, _Tp, _Compare, _Alloc >::empty () const [inline],
[nodiscard], [noexcept]
Returns true if the map is empty. (Which is why begin() would equal end() β that's the vibe check.) π«Ά
end() (const version) π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::end () const
[inline], [noexcept]
Returns a read-only (constant) iterator that points one past the last pair in the map. Iteration happens in ascending order according to the keys, no cap. π
end() (the read/write one) π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::end () [inline], [noexcept]
Returns a read/write iterator that points one past the last pair in the map. Iteration is done in ascending order according to the keys. Same energy, but you can touch stuff. β¨
Referenced by std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::at(), std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::emplace(), std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert(), and std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::operator[]().
equal_range() πΈ
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::pair< iterator, iterator > std::map< _Key, _Tp, _Compare, _Alloc
>::equal_range (const key_type & __x) [inline]
Finds a subsequence matching the given key. detective mode fr fr π
Parameters
__xβ the key of the(key, value)pairs you're trying to locate.
Returns
A pair of iterators that possibly points to the subsequence matching the given key.
This function is equivalent to
std::make_pair(c.lower_bound(val),
c.upper_bound(val))
(but it's faster than making those calls separately, slay).
This function probably only makes sense for multimaps. π€·ββοΈ
equal_range() (const version) π¦
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::pair< const_iterator, const_iterator > std::map< _Key, _Tp,
_Compare, _Alloc >::equal_range (const key_type & __x) const [inline]
Finds a subsequence matching the given key, but make it read-only.
Parameters
__xβ key of the(key, value)pairs to be located.
Returns
A pair of read-only (constant) iterators that possibly points to the subsequence matching the given key.
This one is also equivalent to
std::make_pair(c.lower_bound(val),
c.upper_bound(val))
(again, faster than doing it separately β¨).
And again: this function probably only makes sense for multimaps.
erase() β by heterogeneous key π₯
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<__heterogeneous_tree_key< map > _Kt> size_type std::map< _Key,
_Tp, _Compare, _Alloc >::erase (_Kt && __x) [inline]
Erases elements according to the provided key. bye bestie π
Parameters
__xβ key of the element to be erased.
Returns
The number of elements erased.
This function erases all the elements located by the given key from a map. And a very important note: this function only erases the element. If the element is itself a pointer, the pointed-to memory is not touched in any way. Managing that pointer is on you, bestie β user's responsibility, no cap. β οΈ
erase() β by const key_type& π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> size_type
std::map< _Key, _Tp, _Compare, _Alloc >::erase (const key_type & __x)
[inline]
Erases elements according to the provided key.
Parameters
__xβ key of the element to be erased.
Returns
The number of elements erased.
Erases all the elements located by the given key from a map. Same disclaimer as before and it's giving important: it only erases the element β if that element is a pointer, the pointed-to memory is untouched. You're the main character managing that pointer. π«‘
erase() β the range one βοΈ
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::erase (const_iterator __first,
const_iterator __last) [inline]
Erases a [first,last) range of elements from a map. wipeout π
Parameters
__firstβ iterator pointing to the start of the range to be erased.__lastβ iterator pointing to the end of the range to be erased.
Returns
The iterator __last.
This function erases a whole sequence of elements from a map. And yeah β it only erases the elements. If an element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. β
erase() β by const_iterator position π―
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::erase (const_iterator
__position) [inline]
Erases an element from a map.
Parameters
__positionβ an iterator pointing to the element to be erased.
Returns
An iterator pointing to the element immediately following position prior to the element being erased. If no such element exists, end() is returned.
This function erases an element, pointed to by the given iterator, from a map. Note (again, because it matters): it only erases the element, and if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. π
erase() β by iterator position β¨
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::erase (iterator __position)
[inline]
Erases an element from a map.
Parameters
__positionβ an iterator pointing to the element to be erased.
Returns
An iterator pointing to the element immediately following position prior to the element being erased. If no such element exists, end() is returned.
Erases an element, pointed to by the given iterator, from a map. And yup, the classic: it only erases the element β if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility. π
find() π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::find (const key_type & __x)
[inline]
Tries to locate an element in a map. scavenger hunt era π
Parameters
__xβ key of the(key, value)pair to be located.
Returns
Iterator pointing to the sought-after element, or end() if it's not found.
This function takes a key and tries to locate the element that matches it. If it succeeds, you get an iterator pointing to the sought-after pair. If it fails? You get the past-the-end (end()) iterator. π«Ά
find() β const version π§
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::find (const
key_type & __x) const [inline]
Tries to locate an element in a map.
Parameters
__xβ key of the(key, value)pair to be located.
Returns
Read-only (constant) iterator pointing to the sought-after element, or end() if not found.
Takes a key, tries to locate the element it matches. Success = a constant iterator pointing to the sought-after pair. Failure = the past-the-end (end()) iterator. That's the whole story. π
get_allocator() π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
allocator_type std::map< _Key, _Tp, _Compare, _Alloc >::get_allocator ()
const [inline], [noexcept]
Get a copy of the memory allocation object. that's it, that's the whole function. β¨
insert() β the range one π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _InputIterator> void std::map< _Key, _Tp, _Compare,
_Alloc >::insert (_InputIterator __first, _InputIterator __last)
[inline]
Template function that attempts to insert a range of elements. bringing the whole friend group in π
Parameters
__firstβ iterator pointing to the start of the range to be inserted.__lastβ iterator pointing to the end of the range.
Complexity similar to that of the range constructor.
insert() β the _Pair&& one β
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _Pair> __enable_if_t< is_constructible< value_type,
_Pair >::value, pair< iterator, bool > > std::map< _Key, _Tp, _Compare,
_Alloc >::insert (_Pair && __x) [inline]
Attempts to insert a std::pair into the map.
Parameters
__xβ the pair you wanna insert (peepstd::make_pairif you want the easy way to build pairs, bestie π«Ά).
Returns
- a
pairwhere.firstis an iterator pointing at the possibly-inserted pair, and.secondis aboolthat'strueif the pair actually got inserted. π
So here's the tea: this function attempts to insert a (key, value) pair into the map. A map runs on unique keys, so a pair only gets inserted if its first element (the key) isn't already chillin' in the map. No duplicates, no exceptions, periodt.
Insertion requires logarithmic time.
Referenced bystd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert(), andstd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::operator[]().
π the const-ref one, but make it official
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::pair< iterator, bool > std::map< _Key, _Tp, _Compare, _Alloc
>::insert (const value_type & __x) [inline]
Attempts to insert a std::pair into the map. Iconic behaviour, honestly.
Parameters
__xβ pair to be inserted (seestd::make_pairfor easy creation of pairs).
Returns
- a
pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is aboolthat istrueif the pair was actually inserted.
This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.
Insertion requires logarithmic time.
Referenced bystd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert(), andstd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::operator[]().
π the _Pair&& hint girlie
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
template<typename _Pair> __enable_if_t< is_constructible< value_type,
_Pair >::value, iterator > std::map< _Key, _Tp, _Compare, _Alloc
>::insert (const_iterator __position, _Pair && __x) [inline]
Attempts to insert a std::pair into the map. β¨
Parameters
__positionβ an iterator that serves as a hint as to where the pair should be inserted.__xβ pair to be inserted (seestd::make_pairfor easy creation of pairs).
Returns
- an iterator that points to the element with key of
__x(may or may not be the pair passed in).
This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency β like, none, zero, nada. π
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting. iykyk.
Insertion requires logarithmic time (if the hint is not taken).
π the const value_type& + hint combo
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::insert (const_iterator
__position, const value_type & __x) [inline]
Attempts to insert a std::pair into the map.
Parameters
__positionβ an iterator that serves as a hint as to where the pair should be inserted.__xβ pair to be inserted (seestd::make_pairfor easy creation of pairs).
Returns
- an iterator that points to the element with key of
__x(may or may not be the pair passed in).
This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting.
Insertion requires logarithmic time (if the hint is not taken).
π¦ the value_type&& + hint combo (move edition)
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::insert (const_iterator
__position, value_type && __x) [inline]
Attempts to insert a std::pair into the map.
Parameters
__positionβ an iterator that serves as a hint as to where the pair should be inserted.__xβ pair to be inserted (seestd::make_pairfor easy creation of pairs).
Returns
- an iterator that points to the element with key of
__x(may or may not be the pair passed in).
This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/associative.html#containers.associative.insert_hints for more on hinting.
Insertion requires logarithmic time (if the hint is not taken).
πΈ insert a whole list, main character energy
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> void
std::map< _Key, _Tp, _Compare, _Alloc >::insert (std::initializer_list<
value_type > __list) [inline]
Attempts to insert a list of std::pairs into the map. Bulk insert slay. π
Parameters
__listβ astd::initializer_list<value_type>of pairs to be inserted.
Complexity similar to that of the range constructor.
β the rvalue value_type&& one
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
std::pair< iterator, bool > std::map< _Key, _Tp, _Compare, _Alloc
>::insert (value_type && __x) [inline]
Attempts to insert a std::pair into the map.
Parameters
__xβ pair to be inserted (seestd::make_pairfor easy creation of pairs).
Returns
- a
pair, of which the first element is an iterator that points to the possibly inserted pair, and the second is aboolthat istrueif the pair was actually inserted.
This function attempts to insert a (key, value) pair into the map. A map relies on unique keys and thus a pair is only inserted if its first element (the key) is not already present in the map.
Insertion requires logarithmic time.
π key_comp() β the comparison object, exposed
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
key_compare std::map< _Key, _Tp, _Compare, _Alloc >::key_comp () const
[inline]
Returns the key comparison object out of which the map was constructed. It's giving β¨origin storyβ¨.
Referenced bystd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::at(),std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::emplace(),std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert(), andstd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::operator[]().
π lower_bound() β where the subsequence starts
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::lower_bound (const key_type &
__x) [inline]
Finds the beginning of a subsequence matching given key. π
Parameters
__xβ key of(key, value)pair to be located.
Returns
- iterator pointing to first element equal to or greater than key, or
end().
This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful it returns an iterator pointing to the first element that has a greater value than given key or end() if no such element exists.
Referenced bystd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::at(),std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::emplace(),std::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::insert(), andstd::map< _Key, _Tp, _Cmp, polymorphic_allocator< pair< const _Key, _Tp > > >::operator[]().
π§ lower_bound() const β same but read-only
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::lower_bound
(const key_type & __x) const [inline]
Finds the beginning of a subsequence matching given key.
Parameters
__xβ key of(key, value)pair to be located.
Returns
- read-only (constant) iterator pointing to first element equal to or greater than key, or
end().
This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful it returns an iterator pointing to the first element that has a greater value than given key or end() if no such element exists.
π max_size() β the ceiling
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> size_type
std::map< _Key, _Tp, _Compare, _Alloc >::max_size () const [inline],
[noexcept]
Returns the maximum size of the map. That's it, that's the whole vibe. π
π operator= β copy assignment
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> map &
std::map< _Key, _Tp, _Compare, _Alloc >::operator= (const map< _Key,
_Tp, _Compare, _Alloc > & ) [default]
Map assignment operator. Whether the allocator is copied depends on the allocator traits. (Yeah, that's on the allocator traits, not on you. π)
π operator= β the initializer_list one
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> map &
std::map< _Key, _Tp, _Compare, _Alloc >::operator= (initializer_list<
value_type > __l) [inline]
Map list assignment operator.
Parameters
__lβ aninitializer_list.
This function fills a map with copies of the elements in the initializer list __l.
Note that the assignment completely changes the map and that the resulting map's size is the same as the number of elements assigned. No leftovers, no crumbs, full reset bestie. π
π¦ operator= β move assignment
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> map &
std::map< _Key, _Tp, _Compare, _Alloc >::operator= (map< _Key, _Tp,
_Compare, _Alloc > && ) [default]
Move assignment operator. πβ¨
π₯ operator[] β subscript access, the iconic one
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
mapped_type & std::map< _Key, _Tp, _Compare, _Alloc >::operator[] (const
key_type & __k) [inline]
Subscript ( [] ) access to map data. The one everybody reaches for first, no cap.
Parameters
__kβ the key for which data should be retrieved.
Returns
- a reference to the data of the
(key,data)pair.
so the subscript ( [] ) operator allows for easy lookup. it returns data associated with the key specified in subscript. if the key does not exist, a pair with that key is created using default values, which is then returned. so it's not just lookup, it also creates a default pair if you ask for something that's not there π
. if a heterogeneous key matches a range of elements, the first one is chosen. and lookup? requires logarithmic time. so it's fast but not magic.
πΈ rbegin() const β read-only reverse iterator, last pair first πΈ
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::rbegin
() const [inline], [noexcept]
returns a read-only (constant) reverse iterator that points to the last pair in the map. iteration is done in descending order according to the keys. so you're going backwards, bestie, and you can't change anything. periodt.
π₯ rbegin() β read/write reverse iterator, last pair first π₯
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::rbegin ()
[inline], [noexcept]
returns a read/write reverse iterator that points to the last pair in the map. iteration is done in descending order according to the keys. now you can actually modify stuff, slay.
β¨ rend() const β read-only reverse iterator, one before first β¨
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::rend ()
const [inline], [noexcept]
returns a read-only (constant) reverse iterator that points to one before the first pair in the map. iteration is done in descending order according to the keys. it's the reverse end, the boundary, the vibe check of the reverse world.
π¦ rend() β read/write reverse iterator, one before first π¦
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
reverse_iterator std::map< _Key, _Tp, _Compare, _Alloc >::rend ()
[inline], [noexcept]
returns a read/write reverse iterator that points to one before the first pair in the map. iteration is done in descending order according to the keys. yes, it's the mirror of rbegin() but for the end. iconic.
π size() β how many elements? π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> size_type
std::map< _Key, _Tp, _Compare, _Alloc >::size () const [inline],
[noexcept]
returns the size of the map. literally the number of elements, no cap. so you know how big your map is, bestie.
π
swap() β trade data with another map π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> void
std::map< _Key, _Tp, _Compare, _Alloc >::swap (map< _Key, _Tp, _Compare,
_Alloc > & __x) [inline], [noexcept]
swaps data with another map. __x is a map of the same element and allocator types.
this exchanges the elements between two maps in constant time. (it's only swapping a pointer, an integer, and an instance of the Compare type (which itself is often stateless and empty), so it should be quite fast.) note that the global std::swap() function is specialized such that std::swap(m1,m2) will feed to this function.
whether the allocators are swapped depends on the allocator traits. so it's fast, but allocator swapping is a whole thing. iykyk.
π upper_bound(const key_type & __x) β end of a matching subsequence π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >> iterator
std::map< _Key, _Tp, _Compare, _Alloc >::upper_bound (const key_type &
__x) [inline]
finds the end of a subsequence matching given key. __x is the key of the (key, value) pair to be located.
returns an iterator pointing to the first element greater than key, or end(). so it's like, you give it a key, it gives you the first thing after that key. no cap.
π upper_bound(const key_type & __x) const β read-only version π
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
const_iterator std::map< _Key, _Tp, _Compare, _Alloc >::upper_bound
(const key_type & __x) const [inline]
finds the end of a subsequence matching given key. __x is the key of the (key, value) pair to be located.
returns a read-only (constant) iterator pointing to first iterator greater than key, or end(). same vibe as the non-const one but you can't touch anything. periodt.
β value_comp() β comparison object, but for values β
template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >>
value_compare std::map< _Key, _Tp, _Compare, _Alloc >::value_comp ()
const [inline]
returns a value comparison object, built from the key comparison object out of which the map was constructed. so it's like the map's compare but wrapped for values. iykyk.
π Author π
generated automatically by Doxygen for libstdc++ from the source code. so not a human author, just doxygen doing its thing. iconic.
this page is brought to you by libstdc++ and it's the std::map< ...e, _Alloc >(3) manual page. no date shown, but it's giving classic libstdc++ energy. periodt π
β¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms