This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/81482] by-value lambda capture in remove_if


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]