Created on 2024-08-07.00:00:00 last changed yesterday
Proposed resolution:
This wording is relative to N4988.
Modify [forward.list.erasure] as indicated:
template<class T, class Allocator, class U = T> typename forward_list<T, Allocator>::size_type erase(forward_list<T, Allocator>& c, const U& value);-1- Effects: Equivalent to:
return erase_if(c, [&](const auto& elem) -> bool { return elem == value; });
Modify [list.erasure] as indicated:
template<class T, class Allocator, class U = T> typename list<T, Allocator>::size_type erase(list<T, Allocator>& c, const U& value);-1- Effects: Equivalent to:
return erase_if(c, [&](const auto& elem) -> bool { return elem == value; });
[ 2024-08-21; Reflector poll ]
Set status to Tentatively Ready after nine votes in favour during reflector poll.
std::erase
for list
is specified to return
erase_if(c, [&](auto& elem) { return elem == value; })
.
However, the template parameter Predicate
of erase_if
only requires that the
type of decltype(pred(...))
satisfies boolean-testable
, i.e., the
return type of elem == value
is not necessarily bool
.
bool
to avoid some
pedantic cases (demo):
#include <list>
struct Bool {
Bool(const Bool&) = delete;
operator bool() const;
};
struct Int {
Bool& operator==(Int) const;
};
int main() {
std::list<Int> l;
std::erase(l, Int{}); // unnecessary hard error
}
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-11-19 16:09:07 | admin | set | status: ready -> voting |
2024-08-21 14:46:30 | admin | set | messages: + msg14326 |
2024-08-21 14:46:30 | admin | set | status: new -> ready |
2024-08-10 15:41:37 | admin | set | messages: + msg14314 |
2024-08-07 00:00:00 | admin | create |