This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81482] by-value lambda capture in remove_if
- From: "fabian-gcc at kloetzl dot info" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 03 Aug 2017 08:48:53 +0000
- Subject: [Bug libstdc++/81482] by-value lambda capture in remove_if
- Auto-submitted: auto-generated
- References: <bug-81482-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81482
--- Comment #2 from kloetzl <fabian-gcc at kloetzl dot info> ---
I don't think that the runtime cost of the copies is measurable. My bigger
issue is that this quirks exposes the internal behaviour of the algorithm
implementation; In this case the fact that remove_if calls find_if. My
expectation would be that the standard algorithms are opaque.
Another solution might be to implement a compiler warning: If a lambda is
mutable, captures by value and gets passed to a standard algorithm, produce a
warning. This will not catch all problematic cases with internal copies of the
predicate but might avoid the biggest pitfalls.