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

履歴 編集

function
<stacktrace>

std::stacktrace_entry::description(C++23)

string description() const; // (1) C++23

概要

このオブジェクトを説明する文字列を取得する。

この関数は、関数名の文字列が返ることが想定される。ただし、コンパイラの最適化によって関数名の情報が取得できない可能性がある。

戻り値

*thisで表される評価の説明、または空文字列を返す。

例外

内部のデータ構造、または結果文字列のためのメモリ確保ができない場合、std::bad_alloc例外を送出する。

備考

  • この関数はメモリ確保以外のエラーを「利用可能な情報がない」ものとして扱い、その場合は例外を送出しない

#include <iostream>
#include <stacktrace>

void g() {
  std::stacktrace st = std::stacktrace::current();
  std::stacktrace_entry entry = st[0];

  std::cout << entry.description() << std::endl;
}

void f() {
  g();
}

int main() {
  f();
}

出力例 (GCC)

g()

バージョン

言語

  • C++23

処理系