Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::formatter<std::basic_stacktrace>

      From cppreference.com
      <cpp‎ |utility‎ |basic stacktrace
       
       
      Diagnostics library
       
       
      Defined in header<stacktrace>
      template<class Allocator>
      struct formatter<std::basic_stacktrace<Allocator>>;
      (since C++23)

      The template specialization ofstd::formatter forstd::basic_stacktrace<Allocator> allows users to convert a stacktrace object to string usingformatting functions such asstd::format.

      No format specifier is allowed.

      A stacktrace objects is formatted as if by copyingstd::to_string(s) to the output.

      [edit]Example

      Run this code
      #include <format>#include <iostream>#include <stacktrace> int main(){auto trace= std::stacktrace::current();std::cout<<std::format("{}\n", trace);}

      Possible output:

       0# 0x0000000000402D97 in ./prog.exe 1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 2# 0x0000000000402CA9 in ./prog.exe

      [edit]See also

      (C++20)
      defines formatting rules for a given type
      (class template)[edit]
      (C++23)
      prints tostdout or a file stream usingformatted representation of the arguments
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/basic_stacktrace/formatter&oldid=166755"

      [8]ページ先頭

      ©2009-2025 Movatter.jp