最終更新日時(UTC):
が更新

履歴 編集

function
<stacktrace>

std::basic_stacktrace::to_string(C++23)

namespace std {
  template <class Allocator>
  string to_string(const basic_stacktrace<Allocator>& st);
}

概要

文字列化する。

戻り値

stのスタックトレース情報を説明する文字列を返す。

備考

  • 戻り値となる文字列の行数は、size()と等値であるという保証はない

#include <iostream>
#include <stacktrace>

void g() {
  std::string trace = std::stacktrace::current().to_string();
  std::cout << trace << std::endl;
}

void f() {
  g();
}

int main() {
  f();
}

出力例

 0# g() at main.cpp:5
 1# f() at main.cpp:10
 2# main at main.cpp:14

バージョン

言語

  • C++23

処理系