Namespaces
Variants

std::counting_semaphore<LeastMaxValue>:: max

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
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
constexpr std:: ptrdiff_t max ( ) noexcept ;
(自 C++20 起)

返回内部计数器的最大可能值,该值大于或等于 LeastMaxValue

返回值

内部计数器的最大可能值,以 std::ptrdiff_t 表示。

注释

对于特化版本 binary_semaphore LeastMaxValue 等于 1

正如其名称所示, LeastMaxValue 最小 最大值,而非 实际 最大值。因此 max ( ) 可能返回大于 LeastMaxValue 的数值。