Created on 2025-08-16.00:00:00 last changed yesterday
Proposed resolution:
This wording is relative to N5014.
[Drafting note: There are other ways to fix this code while keeping the caching behaviour, but I don't see any particular reason to do so for the definition of the effects.]
Modify [hive.erasure] as indicated:
template<class T, class Allocator, class Predicate> typename hive<T, Allocator>::size_type erase_if(hive<T, Allocator>& c, Predicate pred);-2- Effects: Equivalent to:
auto original_size = c.size(); for (auto i = c.begin(), last = c.end(); i !=lastc.end(); ) { if (pred(*i)) { i = c.erase(i); } else { ++i; } } return original_size - c.size();
[ 2025-08-29; Reflector poll ]
Set status to Tentatively Ready after five votes in favour during reflector poll.
Background: https://github.com/cplusplus/draft/pull/8162
For [hive.erasure] p2, the defining code must not cache the end-iterator. In case the last element of the sequence is removed, the past-the-end iterator will be invalidated. This will trigger UB in the loop condition. Instead, re-evaluate `end()` each time.History | |||
---|---|---|---|
Date | User | Action | Args |
2025-08-29 11:30:22 | admin | set | messages: + msg14974 |
2025-08-29 11:30:22 | admin | set | status: new -> ready |
2025-08-17 09:30:59 | admin | set | messages: + msg14939 |
2025-08-16 00:00:00 | admin | create |