basic_stacktrace_operator_ltlt
basic_stacktrace_operator_ltlt (basic_stacktrace의 스트림 출력 연산자)
이 페이지는 C++23에서 도입된 std::basic_stacktrace의 스트림 출력 연산자에 대해 다루어요. 이 연산자는 basic_stacktrace 객체의 설명을 출력 스트림에 삽입해요. std::to_string(st)를 호출한 결과를 os에 출력하는 것과 동일하게 동작해요.
출처: cppreference
본문
정의
<stacktrace> 헤더에 정의됨 |
||
|---|---|---|
template < class Allocator > std :: ostream & operator << ( std :: ostream & os , const std :: basic_stacktrace < Allocator >& st ); |
(since 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
같이 보기
operator<<(C++23) —stacktrace_entry의 스트림 출력을 수행해요 (함수 템플릿)