Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.15 KB

File metadata and controls

60 lines (44 loc) · 1.15 KB

get_id

  • thread[meta header]
  • std::this_thread[meta namespace]
  • function[meta id-type]
  • cpp11[meta cpp]
namespace std {
namespace this_thread {
  thread::id get_id() noexcept;
}}
  • thread::id[link /reference/thread/thread/id.md]

概要

現スレッドのスレッド識別子を取得する。

戻り値

現在のスレッド、すなわちこの関数を呼び出したスレッドのスレッド識別子を返す。

この関数の戻り値は、デフォルトコンストラクトされたthread::idオブジェクトとは必ず異なる。

例外

送出しない。

#include <iostream>
#include <thread>

int main()
{
  std::cout << "thread_id=" << std::this_thread::get_id() << std::endl;
  return 0;
}
  • std::this_thread::get_id()[color ff0000]

出力例

thread_id=538af0

バージョン

言語

  • C++11

処理系

参照