GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::stacktrace_entry::source_file - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. stacktrace
  3. stacktrace_entry
  4. source_file

最終更新日時: 2024年06月11日 22時45分38秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<stacktrace>

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

string source_file() 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.source_file() << std::endl;
}

void f() {
  g();
}

int main() {
  f();
}

出力例 (GCC)

/app/example.cpp

バージョン

言語

  • C++23

処理系

  • Clang: ??
  • GCC: 12 ✅
  • Visual C++: ??
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.