std::flat_map::rbegin,(3)
π std::flat_map::rbegin,(3) π
Okay bestie, this page is from the C++ Standard Libary manual, and it's all about std::flat_map::rbegin, β reverse iterator energy for std::flat_map, plus the const twin crbegin(). Let's go π
π NAME π
std::flat_map::rbegin, β that's the name, comma and all. The original NAME line literally reads std::flat_map::rbegin, - std::flat_map::rbegin, β¨
πΈ 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)
Three overloads, all noexcept, all since C++23: regular rbegin() is (1), the const rbegin() is (2), and crbegin() is (3). Slay π«Ά
Returns a reverse iterator to the first element of the reversed flat_map. It corresponds to the last element of the non-reversed flat_map. If the flat_map is empty, the returned iterator is equal to rend().
There's also a diagram named range-rbegin-rend.svg in the original β very visual, very range-rbegin-to-rend π
π«Ά Parameters π«Ά
(none) β literally nothing to pass, bestie π
β¨ Return value β¨
Reverse iterator to the first element.
π₯ Complexity π₯
Constant.
π Notes π
The underlying iterator of the returned reverse iterator is the end iterator. Hence the returned iterator is invalidated if and when the end iterator is invalidated.
β οΈ Translation: this reverse iterator is riding on the end iterator, so if the end iterator gets invalidated, your returned iterator gets invalidated too. Don't ignore that, bestie π
π¦ Example π¦
The original page says // Run this code before the snippet, so here's the snippet:
#include <iomanip>
#include <iostream>
#include <string_view>
#include <flat_map>
int main()
{
const std::flat_map<int, std::string_view> coins
{
{10, "dime"},
{100, "dollar"},
{50, "half dollar"},
{5, "nickel"},
{1, "penny"},
{25, "quarter"}
}; // initializer entries in name alphabetical order
std::cout << "US coins in circulation, largest to smallest denomination:\n";
for (auto it = coins.crbegin(); it != coins.crend(); ++it)
std::cout << std::setw(11) << it->second << " = Β’" << it->first << '\n';
}
π Output π
US coins in circulation, largest to smallest denomination:
dollar = Β’100
half dollar = Β’50
quarter = Β’25
dime = Β’10
nickel = Β’5
penny = Β’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)
Byeee π«Ά β source/version is http://cppreference.com, dated 2024.06.10, for the page std::flat_map::rbegin,(3). Mwah π
π¦ 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