[libcxx-commits] [PATCH] D101948: [libc++] Future-proof std::copy for ranges

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 5 14:56:18 PDT 2021


ldionne created this revision.
Herald added subscribers: mgrang, mgorny.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

When we eventually get to implementing algorithms on ranges, we'll want
to avoid re-writing the algorithms from scratch. To do so, we'll need to
refactor how we write algorithms so that the same core implementation can
be used by both normal algorithms and ranges algorithms. The ranges
algorithms can't just call the iterator ones because the ranges algorithms
are more general (e.g. they accept an iterator and a sentinel).

The trick is to factor the algorithm into a private name and make sure
it works on an (iterator, sentinel) pair, and then use that from the
normal algorithm. Once we add the ranges algorithm, we will only need
to shim the result into the appropriate ranges result type (in_out_result
for ranges::copy).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101948

Files:
  libcxx/include/CMakeLists.txt
  libcxx/include/__algorithm/copy.h
  libcxx/include/__algorithm/unwrap_iter.h
  libcxx/include/algorithm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101948.343203.patch
Type: text/x-patch
Size: 11506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210505/3dd868db/attachment-0001.bin>


More information about the libcxx-commits mailing list