Closed wg21bot closed 4 years ago
See P1865 Add max() to latch and barrier cplusplus/papers#617
It is not a tragedy if we (in '20, towards responding to US 365)... Specify an implementation-defined maximum count for latches and barriers 15 Have only undefined behavior as the outcome if the maximum count is to be exceeded 9 Have a value_type member to specify the count type instead of ptrdiff_t 9 Mandate an error check (like an exception) if this count is exceeded 10 Have a ::max() member to query the value of this count 17 Have a least_max template argument to override this count 15
Recommend we add a least_max template argument with an implementation-defined default
value and ::max() member (match counting_semaphore<>), in response to US 365:
template
LEWG in Belfast: We disagree with the change to class template, the R0 of this paper is better (see notes). Forward P1865R0 to LWG for C++20.
(Prioritization on this vs. other paper-sized NB comments will be shared with LWG chair when LEWG finishes NB comment processing.)
Reviewed by LWG in Belfast on Thu afternoon. Unanimous consent with 2 minor changes for c++20.
Accepted with modification. See paper P1865R1.
latch and barrier currently take a ptrdiff_t as their expected count parameter and thus must support any expected count (larger than or equal to 0) that will fit in a ptrdiff_t. This limits implementation freedom; some platforms can provide a much more efficient implementation of latch and barrier if they can restrict the maximum possible expected count.
Proposed change: Adopt P1865, which adds a static constexpr ptrdiff_t max() noexcept; member to both classes that returns the expressible range of the object, like the one on counting_semaphore.