This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Eliminate needless `add_lvalue_reference` from <algorithm> helpers. NFCI.
ClosedPublic

Authored by Quuxplusone on Aug 19 2021, 12:11 PM.

Details

Summary

When _Compare is a function parameter already (so it's not void and it's not an abominable function type), add_lvalue_reference_t<_Compare> is simply a synonym for _Compare&. We don't need to pull in <type_traits> and instantiate a template trait to figure that out.

Inspired by D108393.

This is arguably one small step on the path to eventually rationalizing our __comp_ref_type weirdness. (Ultimately, we want our internal predicate type never to be a reference type, so that we can stop specifying template arguments explicitly. This definitely doesn't get us there, but at least it eliminates some reducible complexity in the same general area.)

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Aug 19 2021, 12:11 PM
Quuxplusone created this revision.
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Aug 20 2021, 12:04 PM

LGTM. I landed D108393 separately because those were orthogonal changes IMO. Please rebase and merge this!

This revision is now accepted and ready to land.Aug 20 2021, 12:04 PM