[Bug libstdc++/87037] vector :: erase return value should be marked "must use"
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 21 08:09:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87037
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
There's nothing strange about that at all. There are plenty of uses for erase
where it's totally fine to ignore the return value.
auto iter = std::find(v.begin(), v.end(), val);
if (iter != v.end())
{
do_something(*iter);
v.erase(iter);
}
How do you propose to mark it so it only complains when you have a bug?
More information about the Gcc-bugs
mailing list