std::stacktrace_entry(3)
π std::stacktrace_entry (a.k.a. the C++ Standard Library drama, cppreference edition)
okay bestie, so you know how the C++ Standard Libary manual lives at http://cppreference.com? yeah. this is that page. and today we're learning about the single most β¨iconicβ¨ little detective in the whole <stacktrace> header π
πΈ NAME πΈ
std::stacktrace_entry β literally std::stacktrace_entry, that's it, that's the name, no cap π
It's Defined in header <stacktrace> and it showed up like:
class stacktrace_entry; (since C++23)
(yeah she's a C++23 girlie, she wasn't at the function before that π )
π¦ Synopsis π¦
okay so the stacktrace_entry class provides operations for querying information about an evaluation in a stacktrace. read that again. it's giving little index card for one moment in your call stack π
Each stacktrace_entry object is either empty, or it represents an evaluation in a stacktrace. no in-between, no "it's complicated", it's a binary vibe check β¨
Also, and this is the part where she ate: stacktrace_entry models std::regular and std::three_way_comparable<std::strong_ordering>. yes ma'am, three-way comparison, ordering, the whole package π
π§ Member types π§
native_handle_type(C++23) β implementation-defined native handle type. iykyk, it's whatever your implementation says it is, we don't make the rules π«Ά
β Member functions β
- constructor (C++23) β constructs a new
stacktrace_entry. (public member function) β¨ - destructor (C++23) β destroys the
stacktrace_entry. (public member function) π operator=(C++23) β assigns the contents of onestacktrace_entryto another. (public member function) π
π Observers π
native_handleβ gets the implementation-defined native handle of thestacktrace_entry. (C++23) (public member function) π¦operator boolβ checks whether thestacktrace_entryis empty. (C++23) (public member function) β this is your "is she real or is she nothing" check, lowkey essential πΈ
π Query
descriptionβ gets the description of the evaluation represented by thestacktrace_entry. (C++23) (public member function) πsource_fileβ gets the name of the source file that lexically contains the expression or statement whose evaluation is represented by thestacktrace_entry. (C++23) (public member function) πβ¨source_lineβ gets the line number that lexically relates the evaluation represented by thestacktrace_entry. (C++23) (public member function) π’π
(and yes "lexically" is doing a lot of heavy lifting in both of those, don't come for her, it's the correct word, leave her alone π)
π Non-member functions π
operator==,operator<=>β compares twostacktrace_entryvalues. (function) (C++23) β comparing your little stack crumbs, love that for us βto_stringβ returns a string with a description of thestacktrace_entry. (C++23) (function) β string-ification, slay πoperator<<β performs stream output ofstacktrace_entry. (C++23) (function template) β now she can go straight into yourstd::coutlike the main character she is ππ₯
π Helper classes π
std::hash<std::stacktrace_entry>β hash support forstd::stacktrace_entry. (C++23) (class template specialization) π§std::formatter<std::stacktrace_entry>β formatting support forstacktrace_entry. (C++23) (class template specialization) β¨
like, hashable AND formattable?? she's booked and busy fr fr π
π Notes π
boost::stacktrace::frame (available in Boost.Stacktrace) can be used instead when std::stacktrace_entry is not available. so if your compiler is being a hater and you don't have the C++23 goodness yet, Boost has you, bestie π«Ά
Also here's the feature-test macro, so you can vibe-check your toolchain:
__cpp_lib_stacktraceβ value202011Lβ Std C++23 β feature: Stacktrace library π
(go look it up with __cpp_lib_stacktrace before you come crying to me that it doesn't compile, i'm literally begging π)
π Example π
This section is incomplete.
Reason: no example π
yeah. we know. it's giving "the homework was due and nobody did it". tragic. but honestly? no example is still an example of something, periodt π
π«Ά See also π«Ά
basic_stacktrace(C++23) β approximate representation of an invocation sequence consists of stacktrace entries. (class template) π¦ β the big picture, the whole group chat if you willsource_location(C++20) β a class representing information about the source code, such as file names, line numbers, and function names. (class) πΈ β her older cousin who's been doing this since C++20 and never lets anyone forget it
π Category π
- Todo no example
(yeah, the category literally just says todo. love that journey for us πβ¨)
okay that's the whole page bestie, go forth and stacktrace responsibly π remember: every flag, every member function, every "lexically", all of it stayed exactly where it was β i just made it cute. no cap, no invented behavior, just vibes and accurate documentation π
β signed off from <stacktrace>, brought to you by http://cppreference.com, version 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