Namespaces
Variants

std:: formatter <std::basic_stacktrace>

From cppreference.net
헤더 파일에 정의됨 <stacktrace>
template < class Allocator >
struct formatter < std:: basic_stacktrace < Allocator >> ;
(C++23부터)

std::formatter 의 템플릿 특수화는 std::basic_stacktrace<Allocator> 에 대해 사용자가 스택 트레이스 객체를 포맷팅 함수 를 사용하여 문자열로 변환할 수 있도록 합니다. 예를 들어 std::format 과 같은 함수를 사용할 수 있습니다.

형식 지정자는 허용되지 않습니다.

스택트레이스 객체 s 는 마치 std::to_string ( s ) 를 출력에 복사하는 것처럼 포맷됩니다.

예제

#include <format>
#include <iostream>
#include <stacktrace>
int main()
{
    auto trace = std::stacktrace::current();
    std::cout << std::format("{}\n", trace);
}

가능한 출력:

 0# 0x0000000000402D97 in ./prog.exe
 1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
 2# 0x0000000000402CA9 in ./prog.exe

참고 항목

(C++20)
주어진 타입에 대한 서식 규칙을 정의함
(클래스 템플릿)
(C++23)
인수의 서식화된 표현을 사용하여 stdout 또는 파일 스트림에 출력함
(함수 템플릿)