[libcxx-commits] [PATCH] D108400: [libc++] Eliminate needless `add_lvalue_reference` from <algorithm> helpers. NFCI.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 19 12:11:56 PDT 2021


Quuxplusone created this revision.
Quuxplusone added a reviewer: ldionne.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: libcxx-commits, sstefan1.
Herald added a reviewer: libc++.

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 <https://reviews.llvm.org/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.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108400

Files:
  libcxx/include/__algorithm/comp_ref_type.h
  libcxx/include/__algorithm/equal.h
  libcxx/include/__algorithm/find_end.h
  libcxx/include/__algorithm/is_permutation.h
  libcxx/include/__algorithm/lower_bound.h
  libcxx/include/__algorithm/partition.h
  libcxx/include/__algorithm/remove_if.h
  libcxx/include/__algorithm/search.h
  libcxx/include/__algorithm/search_n.h
  libcxx/include/__algorithm/sort.h
  libcxx/include/__algorithm/stable_partition.h
  libcxx/include/__algorithm/unique.h
  libcxx/include/__algorithm/unique_copy.h
  libcxx/include/__algorithm/upper_bound.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108400.367584.patch
Type: text/x-patch
Size: 16453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210819/a99bc802/attachment.bin>


More information about the libcxx-commits mailing list