std::basic_...race::crend(3)
okay so this is from the C++ Standard Libary manual (their spelling, not mine, bestie π) for std::basic_...race::crend(3). Buckle up, we're doing reverse iterators.
β¨ NAME β¨
std::basic_stacktrace::rend, std::basic_stacktrace::crend β yep, it's giving std::basic_stacktrace::rend, std::basic_stacktrace::crend, the reverse-end duo. π
πΈ Synopsis πΈ
Two overloads, both const noexcept, both since C++23:
const_reverse_iterator rend() const noexcept; (1) (since C++23)
const_reverse_iterator crend() const noexcept; (2) (since C++23)
So what's the vibe? These return a reverse iterator pointing past the last entry of the reversed basic_stacktrace. It corresponds to the iterator preceding the first entry of the original basic_stacktrace. This iterator acts as a placeholder β attempting to dereference it results in undefined behavior. π«
There's also this little diagram moment: range-rbegin-rend.svg π
β οΈ bestie, do not dereference this placeholder iterator. That's undefined behavior. It's not a fun surprise, it's a no-cap warning. π
π Parameters π
(none) β literally zero parameters, not a single one. π«Ά
π¦ Return value π¦
The end iterator of the reversed basic_stacktrace.
β Complexity β
Constant.
π Example π
// Run this code
#include <algorithm>
#include <iostream>
#include <stacktrace>
int main()
{
auto trace = std::stacktrace::current();
auto empty_trace = std::stacktrace{};
// Print stacktrace.
std::for_each(trace.rbegin(), trace.rend(),
[](const auto& f) { std::cout << f << '\n'; });
if (empty_trace.rbegin() == empty_trace.rend())
std::cout << "stacktrace 'empty_trace' is indeed empty.\n";
}
π Possible output π
0x0000000000402A29 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x0000000000402BA5 in ./prog.exe
stacktrace 'empty_trace' is indeed empty.
π See also π
rbeginβ returns a reverse iterator to the beginningcrbeginβ (public member function)
catch you later, bestie π β source/version: http://cppreference.com; date: 2024.06.10; page: std::basic_...race::crend(3).
π¦ 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