sequential_erase: amend the predicate passed to erase_if

LWG4135 applies to the quoted Standard paragraph (and therefore
to our own code as well).

https://cplusplus.github.io/LWG/issue4135

Pick-to: 6.8
Change-Id: I05caa4cba001ecc473412c789738480d8eafa0c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 41ffc92f18a1a492720d432f00761e5574076060)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2025-03-08 00:52:21 +01:00 committed by Qt Cherry-pick Bot
parent e8de198ef7
commit 275a47b92c

View File

@ -372,7 +372,7 @@ template <typename Container, typename T>
auto sequential_erase(Container &c, const T &t) auto sequential_erase(Container &c, const T &t)
{ {
// use the equivalence relation from http://eel.is/c++draft/list.erasure#1 // use the equivalence relation from http://eel.is/c++draft/list.erasure#1
auto cmp = [&](auto &e) { return e == t; }; auto cmp = [&](const auto &e) -> bool { return e == t; };
return sequential_erase_if(c, cmp); // can't pass rvalues! return sequential_erase_if(c, cmp); // can't pass rvalues!
} }