std::operat...stacktrace)(3)
๐ธ NAME ๐ธ
okay so bestie, welcome to std::operator<<(std::basic_stacktrace) โ page title std::operat...stacktrace)(3), from the C++ Standard Libary manual (yes, that's the exact spelling in the header, don't come for me ๐). The NAME line is literally std::operator<<(std::basic_stacktrace) - and then std::operator<<(std::basic_stacktrace) again, so likeโฆ it's the same function, we get it, she's iconic ๐
.
โจ Synopsis โจ
Defined in header <stacktrace> ๐ฆ
template< class Allocator >
std::ostream& operator<<( std::ostream& os, const
std::basic_stacktrace<Allocator>& st );
(since C++23) โ yes bestie, C++23 and onward, no cap.
It inserts the description of st into the output stream os. Equivalent to return os << std::to_string(st);. That's the whole assignment, and she ate ๐ฅ.
๐ Parameters ๐
osโ an output streamstโ abasic_stacktracewhose description is to be inserted
๐ Return value ๐
It returns os. Periodt. ๐ซถ
โ ๏ธ Exceptions โ ๏ธ
May throw implementation-defined exceptions. So like, don't assume it's a no-throw girlie, okay? ๐ญ
๐ Example ๐
Obsessed with this little demo โ it's giving main character stacktrace energy:
// Run this code
#include <stacktrace>
#include <iostream>
int main()
{
std::cout << "The stacktrace obtained in the main function:\n";
std::cout << std::stacktrace::current() << '\n';
[]{
std::cout << "The stacktrace obtained in a nested lambda:\n";
std::cout << std::stacktrace::current() << '\n';
}();
}
๐ฎ Possible output ๐ฎ
The stacktrace obtained in the main function:
0# 0x0000000000402E7B in ./prog.exe
1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
2# 0x0000000000402CD9 in ./prog.exe
The stacktrace obtained in a nested lambda:
0# 0x0000000000402DDA in ./prog.exe
1# 0x0000000000402EB2 in ./prog.exe
2# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
3# 0x0000000000402CD9 in ./prog.exe
๐ See also ๐
operator<<performs stream output ofstacktrace_entryโ(C++23)(function template)
Source/version/date sign-off: this page comes from http://cppreference.com, dated 2024.06.10, and the footer title is std::operat...stacktrace)(3) โ k bye bestie, go print a stacktrace and slay ๐
โจ๐
๐ฆ 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