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

履歴 編集

function
<stacktrace>

std::basic_stacktrace::operator[](C++23)

const_reference operator[](size_type frame_no) const; // (1) C++23

概要

任意の位置の要素を取得する。

事前条件

  • frame_no < size()であること

戻り値

保持しているスタックトレースの履歴の、frame_no番目の要素を返す。

例外

投げない

#include <iostream>
#include <stacktrace>

void g() {
  std::stacktrace st = std::stacktrace::current();
  std::cout << st[0] << std::endl;
}

void f() {
  g();
}

int main() {
  f();
}

出力例

g() at main.cpp:5

バージョン

言語

  • C++23

処理系