std::operator<<(std::basic_stacktrace)
From cppreference.com
< cpp | utility | basic stacktrace
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Diagnostics library
(until C++20*)
(C++17)(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Exception handling failures
(C++11)
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)
(TM TS)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++26)
(C++26)
(C++26)
std::basic_stacktrace
operator<<
Defined in header
<stacktrace>
template< class Allocator >
std::ostream & operator<<( std::ostream & os, const std::basic_stacktrace <Allocator>& st );
(since C++23)
std::ostream & operator<<( std::ostream & os, const std::basic_stacktrace <Allocator>& st );
Inserts the description of st
into the output stream os
. Equivalent to return os << std::to_string (st);.
[edit] Parameters
os
-
an output stream
st
-
a
basic_stacktrace
whose description is to be inserted
[edit] Return value
os
.
[edit] Exceptions
May throw implementation-defined exceptions.
[edit] 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