std::span::...an::crbegin(3)
π NAME π
Okay bestie, welcome to the std::span::...an::crbegin(3) page from the C++ Standard Libary manual. This one is all about std::span::rbegin and std::span::crbegin β and yes, the NAME is literally std::span::rbegin,std::span::crbegin and then std::span::rbegin,std::span::crbegin again. π
β¨
πΈ Synopsis πΈ
constexpr reverse_iterator rbegin() const noexcept; (1) (since C++20)
constexpr const_reverse_iterator crbegin() const noexcept; (2) (since C++23)
Returns a reverse iterator to the first element of the reversed span. It corresponds to the last element of the non-reversed span. If the span is empty, the returned iterator is equal to rend(). π«Ά
range-rbegin-rend.svg
π Parameters π
(none) β literally no parameters, bestie. Not a single one. π
π Return value π
Reverse iterator to the first element. Periodt. β¨
β Complexity β
Constant. Easy peasy.
π¦ 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. This is the important part, bestie: invalidation is real. π
π Example π
Run this code, bestie:
// Run this code
#include <algorithm>
#include <iostream>
#include <iterator>
#include <span>
int main()
{
constexpr std::span<const char>
code{"@droNE_T0P_w$s@s#_SECRET_a,p^42!"};
auto hack = [](const unsigned O) { return O - 0141 < 120; };
std::copy_if(code.rbegin(), code.rend(),
std::ostream_iterator<const char>(std::cout), hack);
std::cout << '\n';
}
π₯ Output: π₯
password
π See also π
rendβ returns a reverse iterator to the endcrendβ (public member function) (C++23)rbeginβ returns a reverse iterator to the beginning of a container or arraycrbeginβ (function template) (C++14)
xoxo, bestie π β source/version: http://cppreference.com Β· date: 2024.06.10 π
π¦ 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