std::basic_...trace::cend(3)
π NAME π
okay bestie, welcome to the std::basic_...trace::cend(3) page from the C++ Standard Libary manual (yes it says βLibaryβ in the header, iconic π). This is the tea on std::basic_stacktrace::end and std::basic_stacktrace::cend:
std::basic_stacktrace::end,std::basic_stacktrace::cend β std::basic_stacktrace::end,std::basic_stacktrace::cend
periodt, thatβs the name, no cap π
β¨ Synopsis β¨
hereβs the exact vibe, bestie:
const_iterator end() const noexcept; (1) (since C++23)
const_iterator cend() const noexcept; (2) (since C++23)
so both of these return an iterator pointing past the last entry of the basic_stacktrace. theyβre your βone past the endβ besties π«Ά
and likeβ¦ this iterator is literally just a placeholder. if you try to dereference it, thatβs undefined behavior π do not do it, bestie, thatβs not the cute kind of surprise.
thereβs also a lil diagram situation mentioned as range-begin-end.svg π iykyk.
π Parameters π
(none) β literally none, zero, nada π«Ά
π Return value π
The end iterator. thatβs it, thatβs the whole answer π
π¦ Complexity π¦
Constant. like, itβs not doing extra work, itβs just constant, periodt β¨
π₯ Example π₯
the manpage says // Run this code, so bestie, hereβs the code, exactly as written:
#include <algorithm>
#include <iostream>
#include <stacktrace>
int main()
{
auto trace = std::stacktrace::current();
auto empty_trace = std::stacktrace{};
// Print stacktrace.
std::for_each(trace.begin(), trace.end(),
[](const auto& f) { std::cout << f << '\n'; });
if (empty_trace.begin() == empty_trace.end())
std::cout << "stacktrace 'empty_trace' is indeed empty.\n";
}
Possible output:
0x0000000000402BA8 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x0000000000402A29 in ./prog.exe
stacktrace 'empty_trace' is indeed empty.
slay, it prints the stacktrace and then confirms empty_trace is indeed empty πΈ
π See also π
beginβ returns an iterator to the beginningcbeginβ (public member function)
go check those out too, bestie, theyβre giving matching set energy π
okay thatβs the whole page! source: http://cppreference.com, dated 2024.06.10, and the page is std::basic_...trace::cend(3). bye bestie, go dereference responsibly (which is to say: donβt dereference the end iterator) ππβ¨
π¦ 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