std::basic_...view::crend(3)
π¦ std::basic_string_view::rend / std::basic_string_view::crend π¦
okay so bestie, welcome to the C++ Standard Libary manual-page energy for std::basic_string_view::rend and std::basic_string_view::crend β the reversed-end duo. Yes, that manual name is exact, typo and all; we donβt edit the lore π
.
πΈ NAME πΈ
std::basic_string_view::rend,std::basic_string_view::crend β std::basic_string_view::rend,std::basic_string_view::crend
Thatβs the whole name block. Weβre talking about the rend / crend pair on std::basic_string_view, and they are literally the main characters here. β¨
β¨ Synopsis β¨
constexpr const_reverse_iterator rend() const noexcept;
constexpr const_reverse_iterator crend() const noexcept;
Both are (since C++17). π«Ά
Returns a reverse iterator to the character following the last character of the reversed view. It corresponds to the character preceding the first character of the non-reversed view. This character acts as a placeholder, and attempting to access it results in undefined behavior. π
π¨ placeholder character alert: do not dereference it. Accessing it = undefined behavior. No cap.
Thereβs a diagram referenced right here too: range-rbegin-rend.svg π.
π Parameters π
(none) β she takes nothing, bestie. Literally no parameters. π«Ά
π Return value π
const_reverse_iterator to the character following the last character. Thatβs the flex. β¨
π₯ Complexity π₯
Constant. β‘
π Example π
// Run this code
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string_view>
int main()
{
std::ostream_iterator<char> out_it(std::cout);
std::string_view str_view("abcdef");
std::copy(str_view.rbegin(), str_view.rend(), out_it);
*out_it = '\n';
std::copy(str_view.crbegin(), str_view.crend(), out_it);
*out_it = '\n';
}
Output:
fedcba
fedcba
π See also π
rbeginβ returns a reverse iterator to the beginningcrbeginβ (public member function)rendβ returns a reverse iterator to the endcrendβ (public member function ofstd::basic_string<CharT,Traits,Allocator>)(C++11)
mwah π thatβs the page, bestie. source: http://cppreference.com, version/date: 2024.06.10, page title: std::basic_...view::crend(3). byeee π«Άβ¨
π¦ 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