[libcxx-commits] [libcxx] [libcxx] patch for implementing ranges::find_last (PR #67270)

Christopher Di Bella via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 15 11:46:31 PST 2023


cjdb wrote:

> > > > I'd prefer it if we implemented `find_last` and `find_last_if` independently, instead of deferring to an implementation function.
> > > 
> > > 
> > > Why?
> > 
> > 
> > It simplifies the implementation so that we can directly call `x == y`, rather than having to go through `std::invoke`, which is currently opaque and bad for debug info.
> 
> It also means we'll have to duplicate optimizations, which significantly increases the complexity of the implementation. Improving the code gen of `std::invoke` seems like a really good idea regardless, so IMO that should be the way to go instead. I'd be happy to work on that with you (you already started working on that, right?).

I thought I replied to this, but evidently not. Yes, I've got a patch for Clang that transforms `std::invoke` directly into its underlying logic. The patch in question needs to have runtime tests added, but is otherwise robust (as far as I know). This, plus transforming the standard function objects into their underlying operations (e.g. `std::equal_to()(x, y)` becoming `x == y`) would permanently eliminate these concerns.

https://github.com/llvm/llvm-project/pull/67270


More information about the libcxx-commits mailing list