std::flat_m...map::rbegin,(3)
π
std::flat_multimap::rbegin β C++ Standard Library, but make it cute π
okay so bestie, this is the std::flat_multimap::rbegin page from the C++ Standard Library β the header line is out here serving std::flat_m...map::rbegin,(3), and the original is spelling it C++ Standard Libary (typo included, periodt). We're gonna cover every single thing so you can reverse-iterate with main character energy. π«Άβ¨
πΈ NAME πΈ
std::flat_multimap::rbegin,βstd::flat_multimap::rbegin,
the commas in the NAME line are not a typo I made, they're canon. respect the commas. π
π¦ Synopsis π¦
reverse_iterator rbegin() noexcept; (1) (since C++23)
const_reverse_iterator rbegin() const noexcept; (2) (since C++23)
const_reverse_iterator crbegin() const noexcept; (3) (since C++23)
okay so overload (1) is the regular rbegin(), overload (2) is the const rbegin(), and overload (3) is crbegin(), also const. all three are noexcept, and all three are since C++23. slay. β¨
So what does it do? It returns a reverse iterator to the first element of the reversed flat_multimap. That corresponds to the last element of the non-reversed flat_multimap. If the flat_multimap is empty, the returned iterator is equal to rend(). there's also a diagram in the original labeled range-rbegin-rend.svg doing its little visual thing. π¦
π Parameters π
none. literally none. (none). we love a low-maintenance function. π
π Return value π
a reverse iterator to the first element. that's it, that's the tea. π
π₯ Complexity π₯
Constant. β‘
π§ Notes π§
okay this part is important, bestie: the underlying iterator of the returned reverse iterator is the end iterator. so the returned iterator is invalidated if and when the end iterator is invalidated. not me warning you about invalidation, but yes, that's the vibe check. π
π Example π
// Run this code
#include <algorithm>
#include <iostream>
#include <string>
#include <flat_map>
int main()
{
std::flat_multimap<std::string, int> map
{
{"β", 1},
{"β", 5},
{"β", 3},
{"β", 7},
{"β", 8},
{"β", 4},
{"β", 6},
{"β", 2}
};
std::cout << "Print out in reverse order using const reverse
iterators:\n";
std::for_each(map.crbegin(), map.crend(),
[](std::pair<const std::string, int> const& e)
{
std::cout << "{ \"" << e.first << "\", " << e.second << "
};\n";
});
map.rbegin()->second = 42; // OK: non-const value is modifiable
// map.crbegin()->second = 42; // Error: cannot modify the const value
}
π Possible output π
Print out in reverse order using const reverse iterators:
{ "β", 8 };
{ "β", 7 };
{ "β", 6 };
{ "β", 5 };
{ "β", 4 };
{ "β", 3 };
{ "β", 2 };
{ "β", 1 };
πΈ See also πΈ
rendβ returns a reverse iterator to the endcrendβ (public member function)rbeginβ returns a reverse iterator to the beginning of a container or arraycrbeginβ (function template) (C++14)
okay that's the whole page, bestie π«Ά source/version + date sign-off: http://cppreference.com, 2024.06.10, and the page name is std::flat_m...map::rbegin,(3). now go reverse-iterate something iconic. π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms