std::formatter<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
formatter<std::basic_stacktrace>
Defined in header
<stacktrace>
template< class Allocator >
struct formatter<std::basic_stacktrace <Allocator>>;
(since C++23)
struct formatter<std::basic_stacktrace <Allocator>>;
The template specialization of std::formatter for std::basic_stacktrace<Allocator> 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
Run this code
#include <format> #include <iostream> #include <stacktrace> 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