This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
hive::reserve() needs Throws: element adjusted to match block min/max considerationsSection: 23.3.9.3 [hive.capacity] Status: New Submitter: Matt Bentley Opened: 2025-09-17 Last modified: 2025-10-22
Priority: 3
View other active issues in [hive.capacity].
View all other issues in [hive.capacity].
View all issues with New status.
Discussion:
This issue comes from Bloomberg as part of their C++26 comments via Incits. To summarize their case, in a
call to reserve(n),
if (n > capacity() && capacity() + current-limits.min > max_size()),
reserve should throw, e.g when max_size=100, capacity=80, current-limits.min and
current-limits.max are 40 and n=90.
max_size() to 140 and n to 130,
we can see that although we could add one block with a capacity of current-limits.min,
adding another would be impossible; we still cannot make capacity >= n without also
being > max_size.
This is currently not stated in the Throws: element. I've implemented the requested additional
throws and they are easily achievable.
[2025-10-22; Reflector poll.]
Set priority to 3 after reflector poll.
There was discussion if reserve() is allowed to deallocate unused blocks,
that materialized into LWG 4380(i).
Proposed resolution:
This wording is relative to N5014.
Modify 23.3.9.3 [hive.capacity] as indicated:
void reserve(size_type n);-3- Effects: If
-4- Postconditions:n <= capacity()istrue, there are no effects. Otherwise increasescapacity()by allocating reserved blocks.capacity() >= nistrue. -5- Throws:length_errorifncapacity()cannot be made>= nwithout being> max_size(), as well as any exceptions thrown by the allocator. […]