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

履歴 編集

function
<semaphore>

std::counting_semaphore::max(C++20)

static constexpr ptrdiff_t max() noexcept;

概要

カウンティングセマフォが取り扱えるカウンタの最大値

戻り値

カウンタの最大値を返す。

カウンタの最大値はテンプレートパラメータleast_max_valueと等しいか、それ以上の値となる。

例外

投げない

#include <iostream>
#include <semaphore>

int main()
{
  using Semaphore = std::counting_semaphore<10>;
  std::cout << Semaphore::max() << std::endl;

  // 処理系定義のデフォルト値
  std::cout << std::counting_semaphore<>::max() << std::endl;
}

出力例

10
2147483647

バージョン

言語

  • C++20

処理系