Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 1.26 KB

File metadata and controls

66 lines (48 loc) · 1.26 KB

operator[]

  • stacktrace[meta header]
  • std[meta namespace]
  • basic_stacktrace[meta class]
  • function[meta id-type]
  • cpp23[meta cpp]
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();
}
  • st[0][color ff0000]
  • current()[link current.md]

出力例 (GCC)

 g() at /app/example.cpp:5

バージョン

言語

  • C++23

処理系

参照