Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      operator<<(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)
      operator<<
      Helper classes
       
      Defined in header<thread>
      template<class CharT,class Traits>

      std::basic_ostream<CharT,Traits>&

          operator<<(std::basic_ostream<CharT,Traits>& ost,std::thread::id id);
      (since C++11)

      Writes a textual representation of a thread identifierid to the output streamost.

      If two thread identifiers compare equal, they have identical textual representations; if they do not compare equal, their representations are distinct.

      Contents

      [edit]Parameters

      ost - output stream to insert the data into
      id - thread identifier

      [edit]Return value

      ost

      [edit]Exceptions

      May throw implementation-defined exceptions.

      [edit]Example

      Run this code
      #include <chrono>#include <iostream>#include <thread>usingnamespace std::chrono; int main(){std::thread t1([]{std::this_thread::sleep_for(256ms);});std::thread t2([]{std::this_thread::sleep_for(512ms);}); std::clog<< t1.get_id()<<'\n'<< t2.get_id()<<'\n';     t1.join();    t2.join();}

      Possible output:

      141592653589793141421356237309
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/thread/id/operator_ltlt&oldid=161281"

      [8]ページ先頭

      ©2009-2026 Movatter.jp