Created on 2025-09-23.00:00:00 last changed 2 weeks ago
Proposed resolution:
This wording is relative to N5014.
Modify [hive.capacity] as indicated:
void reserve(size_type n);-3- Effects: If n <= capacity() is `true`, there are no effects. Otherwise increases `capacity()` by allocating reserved blocks.
-4- Postconditions: capacity() >= n is `true`. -5- Throws: `length_error` if `n` > max_size(), as well as any exceptions thrown by the allocator. -6- Complexity: It does not change the size of the sequence and takes at most linear time in the number of reserved blocks allocated and deallocated. -7- Remarks: All references, pointers, and iterators referring to elements in `*this`, as well as the past-the-end iterator, remain valid.
As noted by Arthur in issue 4379, `reserve(n)` could choose to deallocate some reserved (empty) blocks if in doing so it could then allocate blocks which brought `capacity()` closer to `n`.
For example if `capacity()` is `460`, `n` is `480`, the current-limits.min is `40` and there is a reserved block of capacity `70`, the latter could be deallocated and a new reserved block allocated of capacity `90`, bringing total capacity to `480`. As opposed to allocating a new reserved block at the min capacity of `40`, bringing the total capacity to `500`. The implicit assumption in this issue is that we want `reserve()` to be able to deallocate. No-one has objected to this before, but if you want to, please speak up. Anyway, the Complexity of `reserve()` does not presently reflect this ability.History | |||
---|---|---|---|
Date | User | Action | Args |
2025-09-26 16:04:35 | admin | set | messages: + msg15078 |
2025-09-23 00:00:00 | admin | create |