std::operat...race_entry)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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 β€” a stacktrace_entry whose 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 of basic_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