[libcxx-commits] [PATCH] D149827: [libc++][ranges] Implement the changes to `deque` from P1206 (`ranges::to`):
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 4 10:05:38 PDT 2023
ldionne added inline comments.
================
Comment at: libcxx/include/__algorithm/copy_n.h:42
*__result = *__first;
+ ++__first;
++__result;
----------------
I think this needs a LWG issue.`std::copy_n` and `ranges::copy_n` have the exact same specification (http://eel.is/c++draft/alg.copy#lib:copy_n), but `std::copy_n` seems to be expected not to increment the input iterator if it can avoid it. `ranges::copy_n` does increment the iterator. For something like `istream_iterator`, this means we will be extracting different numbers of elements from the underlying stream.
This feels similar to the `views::take` issue we discussed in Issaquah, it might be worth checking whether that issue did talk about `copy_n` as another case of the same problem.
But for certain, I think we'll break users if we start increment this here, so we shouldn't do it unless we're blessed by the standard explicitly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149827/new/
https://reviews.llvm.org/D149827
More information about the libcxx-commits
mailing list