Closed al-mission-2016 closed 4 years ago
Hi, thanks for the PR!
A couple of comments/requested changes:
for_each.hpp
-- it doesn't need to go in its own header filefor_each_n_result
can just be a using
alias for for_each_result
-- you don't need to duplicate the whole class template (at some point I need to update all the *_result
types to match the C++20 spec, but that's a separate PR)impl()
static function in various algorithms exist to avoid (potentially) having two sets of constraint checks if the range overload were simply to forward to the iter-sentinel overload. But since there is only a single overload of for_each_n
, there is no need for an impl
function -- the algorithm implementation can just go in operator()
.See uninitialized_fill_n
for an example of what I'm after.
Also, importantly, please add tests. Contrary to the above, these should go in their own test/algorithm/for_each_n.cpp
source file. Range-V3 has a test file here which you can adapt for NanoRange (but please make sure to keep the copyright/licence notice intact, of course).
Implemented in #96
Hi, Tristan. After P1243R4
ranges::for_each_n
(as well assample
andclamp
) was added into C++20. http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1243r4.pdf http://eel.is/c++draft/alg.foreach