• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <thread>

    std::jthread::hardware_concurrency

    [[nodiscard]]
    static unsigned int hardware_concurrency() noexcept; // (1) C++20
    static unsigned int hardware_concurrency() noexcept; // (1) C++26
    

    概要

    処理系によりサポートされるスレッド並行数を取得する。

    戻り値

    例外

    送出しない。

    #include <iostream>
    #include <thread>
    
    int main()
    {
      std::cout << "concurrency=" << std::jthread::hardware_concurrency() << std::endl;
      return 0;
    }
    

    出力例

    concurrency=12
    

    バージョン

    言語

    • C++20

    処理系

    参照