[libcxx-commits] [PATCH] D115686: [libc++] [ranges] Introduce _LIBCPP_AUTO_CAST(x) for auto(x)

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 13 16:59:54 PST 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, libc++.
Quuxplusone added a project: libc++.
Herald added a subscriber: mgorny.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

Clang is gaining `auto(x)` support in D113393 <https://reviews.llvm.org/D113393>, but sadly there seems to be no feature-test macro for it.

Use this where C++20 specifies we should use `auto(x)`; stop using `__decay_copy(x)`, which calls more move-constructors than it should.
Add regression tests.

Drive-by fix some places in `std::ranges::size` that were perfect-forwarding when they shouldn't; this affects one test case. Did this only because I was touching those lines already: `__decay_copy(forward(x))` becomes just `_LIBCPP_AUTO_CAST(x)`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115686

Files:
  libcxx/include/CMakeLists.txt
  libcxx/include/__ranges/access.h
  libcxx/include/__ranges/size.h
  libcxx/include/__utility/auto_cast.h
  libcxx/include/module.modulemap
  libcxx/include/utility
  libcxx/test/std/ranges/range.access/range.access.begin/begin.pass.cpp
  libcxx/test/std/ranges/range.access/range.access.end/end.pass.cpp
  libcxx/test/std/ranges/range.access/range.prim/size.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115686.394089.patch
Type: text/x-patch
Size: 13375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211214/60ef77bf/attachment-0001.bin>


More information about the libcxx-commits mailing list