]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make std::erase for linked lists convert to bool
authorJonathan Wakely <jwakely@redhat.com>
Thu, 6 Mar 2025 21:18:21 +0000 (21:18 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 7 Mar 2025 20:36:34 +0000 (20:36 +0000)
commite6e7b477bbdbfb3fee6b44087a59f94fd1e2c7a3
tree90a0d01ebc70514d6648ca247ec5e97e6758b360
parent4b180459626df64dac758da8760d868c2604ddf2
libstdc++: Make std::erase for linked lists convert to bool

LWG 4135 (approved in Wrocław, November 2024) fixes the lambda
expressions used by std::erase for std::list and std::forward_list.
Previously they attempted to copy something that isn't required to be
copyable. Instead they should convert it to bool right away.

The issue resolution also changes the lambda's parameter to be const, so
that it can't modify the elements while comparing them.

libstdc++-v3/ChangeLog:

* include/std/forward_list (erase): Change lambda to have
explicit return type and const parameter type.
* include/std/list (erase): Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Check lambda
is correct.
* testsuite/23_containers/list/erasure.cc: Likewise.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/include/std/forward_list
libstdc++-v3/include/std/list
libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc
libstdc++-v3/testsuite/23_containers/list/erasure.cc