std::basic_string::rbegin,(3)
π NAME π
okay bestie, this is the std::basic_string::rbegin,(3) page from the C++ Standard Libary manual. The NAME line is std::basic_string::rbegin, - std::basic_string::rbegin, β yes, it says it twice and the comma is included, sheβs extra π
.
β¨ Synopsis β¨
Hereβs the synopsis, keep the overload labels and annotations, theyβre part of the lore π«Ά:
reverse_iterator rbegin(); (1) (noexcept since C++11)
(constexpr since C++20)
const_reverse_iterator rbegin() const; (2) (noexcept since C++11)
(constexpr since C++20)
const_reverse_iterator crbegin() const noexcept; (3) (since C++11)
(constexpr since C++20)
So what it does: it returns a reverse iterator to the first character of the reversed string. That corresponds to the last character of the non-reversed string. reverse brainrot but make it useful β¨
Thereβs a diagram named range-rbegin-rend.svg hanging out with this page, btw.
πΈ Parameters πΈ
(none) β zero parameters, nada, no cap π«Ά.
π¦ Return value π¦
Reverse iterator to the first character. Thatβs the whole return value, bestie.
π Complexity π
Constant. Thatβs what it says, and we respect it.
π Notes π
libc++ backports crbegin() to C++98 mode. iykyk π.
π₯ Example π₯
The page says // Run this code, so hereβs the example exactly:
// Run this code
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
int main()
{
std::string s("Exemplar!");
*s.rbegin() = 'y';
std::cout << s << '\n'; // "Exemplary"
std::string c;
std::copy(s.crbegin(), s.crend(), std::back_inserter(c));
std::cout << c << '\n'; // "yralpmexE"
}
π Output: π
Exemplary
yralpmexE
π See also π
rendβ returns a reverse iterator to the endcrendβ (public member function) (C++11)rbeginβ returns a reverse iterator to the beginningcrbeginβ (public member function ofstd::basic_string_view<CharT,Traits>)
source: http://cppreference.com, date: 2024.06.10, page: std::basic_string::rbegin,(3) β bye bestie, go reverse-iterate something cute π
π¦ 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