- semaphore[meta header]
- std[meta namespace]
- counting_semaphore[meta class]
- function[meta id-type]
- cpp20[meta cpp]
constexpr explicit counting_semaphore(ptrdiff_t desired); // (1)
counting_semaphore(const counting_semaphore&) = delete; // (2)- (1) : カウンタ初期値を
desiredとして、counting_semaphoreオブジェクトの初期化を行う。 - (2) : コピーコンストラクタ。コピー不可。
desired >= 0 かつ desired <= max()
投げない
#include <semaphore>
// カウンタ 初期値0/最大値10 のセマフォを定義
std::counting_semaphore<10> sem{0};
// カウンタ 初期値1/最大値1 の(バイナリ)セマフォを定義
// このセマフォはミューテックス相当の排他制御に用いられる
std::counting_semaphore<1> mtx{1};
int main() {}- std::counting_semaphore[color ff0000]
- C++20
- Clang: 11.0 [mark verified]
- GCC: ??
- ICC: ??
- Visual C++: ??