Created on 2023-02-09.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to n4928.
Modify [flat.set.erasure] as indicated:
template<class Key, class Compare, class KeyContainer, class Predicate> typename flat_set<Key, Compare, KeyContainer>::size_type erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
-1- Effects: Equivalent to:auto [erase_first, erase_last] = ranges::remove_if(c, pred); auto n = erase_last - erase_first; c.erase(erase_first, erase_last); return n;-1- Preconditions: Key meets the Cpp17MoveAssignable requirements.
-2- Effects: Let E be bool(pred(as_const(e))). Erases all elements e in c for which E holds. -3- Returns: The number of elements erased. -4- Complexity: Exactly c.size() applications of the predicate. -5- Remarks: Stable ([algorithm.stable]). If an invocation of erase_if exits via an exception, c is in a valid but unspecified state ([defns.valid]). [Note 1: c still meets its invariants, but can be empty. — end note]
Modify [flat.multiset.erasure] as indicated:
template<class Key, class Compare, class KeyContainer, class Predicate> typename flat_multiset<Key, Compare, KeyContainer>::size_type erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
-1- Effects: Equivalent to:auto [erase_first, erase_last] = ranges::remove_if(c, pred); auto n = erase_last - erase_first; c.erase(erase_first, erase_last); return n;-1- Preconditions: Key meets the Cpp17MoveAssignable requirements.
-2- Effects: Let E be bool(pred(as_const(e))). Erases all elements e in c for which E holds. -3- Returns: The number of elements erased. -4- Complexity: Exactly c.size() applications of the predicate. -5- Remarks: Stable ([algorithm.stable]). If an invocation of erase_if exits via an exception, c is in a valid but unspecified state ([defns.valid]). [Note 1: c still meets its invariants, but can be empty. — end note]
[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate → WP. ]
[ Issaquah 2023-02-09; LWG ]
Move to Immediate for C++23
The current specification of erase_if for flat_{,multi}set calls ranges::remove_if on the set, which is obviously incorrect — the set only present constant views of its elements.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2023-02-13 11:31:32 | admin | set | messages: + msg13404 |
2023-02-13 11:31:32 | admin | set | status: immediate -> wp |
2023-02-10 01:20:44 | admin | set | messages: + msg13328 |
2023-02-10 01:20:44 | admin | set | status: new -> immediate |
2023-02-09 18:21:20 | admin | set | messages: + msg13316 |
2023-02-09 00:00:00 | admin | create |