std::operat...race_entry)(3)
π NAME π
std::operator<<(std::stacktrace_entry) β and yeah, the description is literally just std::operator<<(std::stacktrace_entry) again, because the NAME section said it twice and we respect the canon π
okay so real talk, this page comes from the C++ Standard Libary manual β that's the C++ Standard Library, section 3 β and yes, "Libary" is spelled like that in the header, we are not gatekeeping typos here π
β¨ Synopsis β¨
Defined in header <stacktrace>.
std::ostream& operator<<( std::ostream& os, const std::stacktrace_entry& f );
(since C++23) β fresh out the oven, no cap π§
So what does it do? It inserts the description of f into the output stream os. That's the whole vibe. And it's equivalent to:
return os << std::to_string(f);
like, it literally just stringifies and shoves it in the stream. iconic behavior, honestly π
πΈ Parameters πΈ
osβ an output stream. your destination, your canvas, your group chat π¬fβ astacktrace_entrywhose description is to be inserted. the main character of this operation π
π¦ Return value π¦
os β yes, it just hands the stream right back to you. king behavior, chain-friendly, obsessed π«Ά
π₯ Exceptions π₯
May throw implementation-defined exceptions.
β οΈ bestie this is the "unknown unknowns" zone β implementation-defined means your specific standard library gets to decide, so like, read your own implementation's docs, iykyk π
π Example π
// Run this code
#include <iostream>
#include <stacktrace>
int main()
{
for (const auto& f : std::stacktrace::current())
std::cout << f << '\n';
}
Possible output:
0x0000000000402AA7 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x00000000004029B9 in ./prog.exe
look at those stack frames slaying all over the terminal β (and note: possible output β your addresses and paths will differ, don't come for me π)
π See also π
operator<<β performs stream output ofbasic_stracktrace(C++23) (function template)
(yes, basic_stracktrace β that's exactly how it's written here, we're preserving it character for character, periodt π
)
and that's the page, bestie π brought to you by http://cppreference.com, dated 2024.06.10 β mwah, go print some stack traces πβ¨
π¦ 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