std::operator<<(std::basic_stacktrace)
From cppreference.com
< cpp | utility | basic stacktrace
Defined in header <stacktrace>
|
||
template< class CharT, class Traits, class Allocator > std::basic_ostream<CharT, Traits>& operator<<( std::basic_ostream<CharT, Traits>& os, |
(since C++23) | |
Inserts the description of st
into the output stream os
. Equivalent to return os << std::to_string(st);.
Parameters
os | - | an output stream |
st | - | a basic_stacktrace whose description is to be inserted
|
Return value
os
.
Exceptions
May throw implementation-defined exceptions.
Notes
Since std::string can only be outputted by std::ostream (not by e.g. std::wostream), it is effectively required that os
be of type std::ostream&.
Example
Run this code
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
(C++23) |
performs stream output of stacktrace_entry (function template) |