std::formatterstd::basic_stacktrace - cppreference.com (original) (raw)
The template specialization of std::formatter for std::basic_stacktrace allows users to convert a stacktrace object to string using formatting functions such as std::format.
No format specifier is allowed.
A stacktrace object s is formatted as if by copying std::to_string(s) to the output.
[edit] Example
#include #include #include int main() { auto trace = std::stacktrace::current(); std::cout << std::format("{}\n", trace); }
Possible output:
0# 0x0000000000402D97 in ./prog.exe 1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 2# 0x0000000000402CA9 in ./prog.exe