14 #ifndef RANGES_V3_ALGORITHM_FOR_EACH_N_HPP
15 #define RANGES_V3_ALGORITHM_FOR_EACH_N_HPP
21 #include <range/v3/algorithm/result_types.hpp>
29 #include <range/v3/utility/static_const.hpp>
31 #include <range/v3/detail/prologue.hpp>
37 RANGES_FUNC_BEGIN(for_each_n)
43 constexpr I RANGES_FUNC(for_each_n)(I
first, iter_difference_t<I> n, F fun, P proj = P{})
45 RANGES_EXPECT(0 <= n);
47 auto b = uncounted(
first);
48 for(; 0 < n; ++b, --n)
50 return recounted(
first, b, norig);
54 template(
typename Rng,
typename F,
typename P = identity)(
55 requires input_range<Rng> AND
57 constexpr borrowed_iterator_t<Rng> RANGES_FUNC(for_each_n)(
58 Rng && rng, range_difference_t<Rng> n, F fun, P proj = P{})
61 RANGES_EXPECT(n <= distance(rng));
63 return (*
this)(begin(rng), n, detail::move(fun), detail::move(proj));
66 RANGES_FUNC_END(for_each_n)
70 using ranges::for_each_n;
75 #include <range/v3/detail/epilogue.hpp>
template(typename I, typename F, typename P=identity)(requires input_iterator< I > AND indirectly_unary_invocable< F
function template for_each_n
CPP_concept indirectly_unary_invocable
\concept indirectly_unary_invocable
Definition: concepts.hpp:545
CPP_concept input_iterator
\concept input_iterator
Definition: concepts.hpp:362
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition: meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
Definition: identity.hpp:25