Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::formatter<std::thread::id>

      From cppreference.com
      <cpp‎ |thread‎ |thread‎ |id
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Condition variables
      (C++11)
      Semaphores
      Latches and Barriers
      (C++20)
      (C++20)
      Futures
      (C++11)
      (C++11)
      (C++11)
      Safe reclamation
      Hazard pointers
      Atomic types
      (C++11)
      (C++20)
      Initialization of atomic types
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
       
      std::thread::id
      Member functions
      Non-member functions
      (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
      Helper classes
      formatter<std::thread::id>
      (C++23)
       
      Defined in header<thread>
      template<class CharT>
      struct formatter<std::thread::id, CharT>;
      (since C++23)

      The template specialization ofstd::formatter for thestd::thread::id class allows users to convert a thread identifier to its textual representation usingformatting functions.

      Contents

      [edit]Format specification

      The syntax of format specifications is:

      fill-and-align (optional)width (optional)

      fill-and-align andwidth have the same meaning as instandard format specification. The default alignment is>.

      The formatted output matches the output ofoperator<<, adjusted as appropriate for the format specifiers.

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_formatters202302L(C++23)Formattingstd::thread::id andstd::stacktrace

      [edit]Example

      Run this code
      #include <format>#include <iostream>#include <thread> int main(){std::thread::id this_id=std::this_thread::get_id();std::thread::id null_id; std::cout<<std::format("current thread id: {}\n", this_id);std::cout<<std::format("{:=^10}\n", null_id);}

      Possible output:

      current thread id: 140046396632256====0=====

      [edit]See also

      (C++20)
      defines formatting rules for a given type
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/thread/id/formatter&oldid=159682"

      [8]ページ先頭

      ©2009-2026 Movatter.jp