std::map::r...ap::crbegin(3)
π NAME π
Welcome to the C++ Standard Libary page for std::map::r...ap::crbegin(3) β yes, βLibaryβ is spelled exactly like that in the manual name, and we are not fixing it, periodt. π
std::map::rbegin,std::map::crbegin - std::map::rbegin,std::map::crbegin
Thatβs the name, bestie. No cap.
π¦ Synopsis π¦
Here are the signatures, looking iconic:
reverse_iterator rbegin(); (1) (noexcept since C++11)
const_reverse_iterator rbegin() const; (2) (noexcept since C++11)
const_reverse_iterator crbegin() const noexcept; (3) (since C++11)
Okay so this returns a reverse iterator to the first element of the reversed map. It corresponds to the last element of the non-reversed map. If the map is empty, the returned iterator is equal to rend() β empty-map behavior, iykyk.
Thereβs a lil diagram named range-rbegin-rend.svg in the original page β visual support, slay. π¦
πΈ Parameters πΈ
(none) β literally no parameters. Zero. Zilch. She takes nothing and still serves. π
β¨ Return value β¨
Reverse iterator to the first element. Thatβs the whole return value, no extra lore. π
β Complexity β
Constant. Thatβs it. Iconic and constant. β
π«Ά Notes π«Ά
Invalidation tea: 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. So like, if the end iterator gets invalidated, your returned reverse iterator gets invalidated too β important vibe check, no cap. π
Also, libc++ backports crbegin() to C++98 mode. Cute. Time travel behavior, iykyk. π°οΈβ¨
π» Example π»
Run this code, bestie:
// Run this code
#include <iomanip>
#include <iostream>
#include <string_view>
#include <map>
int main()
{
const std::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) (C++11)rbeginβ returns a reverse iterator to the beginning of a container or arraycrbeginβ (function template) (C++14)
Thatβs the page, bestie! Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::map::r...ap::crbegin(3). Byeeee, 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