• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <stacktrace>

    std::basic_stacktrace::to_string

    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::to_string(std::stacktrace::current());
      std::cout << trace << std::endl;
    }
    
    void f() {
      g();
    }
    
    int main() {
      f();
    }
    

    出力例 (GCC)

       0#  g() at /app/example.cpp:5
       1#  f() at /app/example.cpp:10
       2# main at /app/example.cpp:14
       3#      at :0
       4#      at :0
       5# _start at :0
       6# 
    

    バージョン

    言語

    • C++23

    処理系