名前空間
変種
操作

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

From cppreference.com
 
 
 
 
ヘッダー <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

[編集] 関連項目

stacktrace_entry のストリーム出力を実行します。
(関数テンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)