https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100940
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to TC from comment #4) > (In reply to Patrick Palka from comment #3) > > Good point, confirmed. Though I'm not sure if perfect forwarding here is > > strictly necessary to fix this testcase. Perhaps the > > _S_has_simple_extra_args versions of _Partial should be forwarding the bound > > arguments as prvalues instead of as const lvalues? > > It's pretty easy to come up with counterexamples that don't work (for > example, the type might be move-only). > > It may be better to limit the "simple" case for take/drop to when the > argument type is integer-like; that's like 99% of uses anyway. Contrived > examples gets the perfect forwarding fun but that's fine. > > Similarly, it might be a good idea to restrict the "simple" case for the > other adaptors a bit - perhaps to the case where the predicate is trivially > copyable, which should still give good diagnostic for a lot of uses, but > avoids a performance hit if the function object at issue is > like...std::function. That makes sense to me. Implementation wise I guess this would mean parameterizing the _S_has_simple_extra_args flag by the actual types of the extra arguments. And I suppose we could also use this to declare some partial applications of split to be simple, e.g. when the pattern argument is a scalar or a view, and get good diagnostics for split in these cases.