Namespaces
Variants

std:: operator<< (std::basic_stacktrace)

From cppreference.net
헤더 파일에 정의됨 <stacktrace>
template < class Allocator >
std:: ostream & operator << ( std:: ostream & os, const std:: basic_stacktrace < Allocator > & st ) ;
(C++23부터)

st 의 설명을 출력 스트림 os 에 삽입합니다. return os << std:: to_string ( st ) ; 와 동일합니다.

목차

매개변수

os - 출력 스트림
st - 설명이 삽입될 basic_stacktrace

반환값

os .

예외

구현 정의 예외를 던질 수 있습니다.

예제

#include <stacktrace>
#include <iostream>
int main()
{
    std::cout << "The stacktrace obtained in the main function:\n";
    std::cout << std::stacktrace::current() << '\n';
    []{
        std::cout << "The stacktrace obtained in a nested lambda:\n";
        std::cout << std::stacktrace::current() << '\n';
    }();
}

가능한 출력:

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

참고 항목

(C++23)
stacktrace_entry 의 스트림 출력을 수행합니다
(함수 템플릿)