Iros
Loading...
Searching...
No Matches
for_each_n.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
di/container/algorithm/in_fun_result.h
"
4
#include "
di/container/concepts/prelude.h
"
5
#include "
di/container/meta/prelude.h
"
6
#include "
di/function/identity.h
"
7
#include "
di/function/invoke.h
"
8
#include "
di/util/reference_wrapper.h
"
9
10
namespace
di::container
{
11
namespace
detail
{
12
struct
ForEachNFunction
{
13
template
<concepts::InputIterator Iter,
typename
SSizeType = meta::IteratorSSizeType<Iter>,
14
typename
Proj = function::Identity, concepts::IndirectlyUnaryInvocable<meta::Projected<Iter, Proj>> F>
15
constexpr
auto
operator()
(Iter first,
meta::TypeIdentity<SSizeType>
n, F f, Proj
proj
= {})
const
16
->
InFunResult<Iter, F>
{
17
for
(SSizeType i = 0; i < n; ++i, ++first) {
18
function::invoke
(f,
function::invoke
(
proj
, *first));
19
}
20
return
{ util::move(first), util::move(f) };
21
}
22
};
23
}
24
25
constexpr
inline
auto
for_each_n
=
detail::ForEachNFunction
{};
26
}
27
28
namespace
di
{
29
using
container::for_each_n
;
30
}
identity.h
in_fun_result.h
prelude.h
prelude.h
invoke.h
di::container::detail
Definition
sequence.h:13
di::container
Definition
sequence.h:12
di::container::for_each_n
constexpr auto for_each_n
Definition
for_each_n.h:25
di::function::invoke
constexpr auto invoke
Definition
invoke.h:100
di::meta::TypeIdentity
Type< TypeConstant< T > > TypeIdentity
This is a helper template to prevent C++ from deducing the type of template argument.
Definition
core.h:32
di
Definition
zstring_parser.h:9
di::proj
constexpr auto proj
Definition
proj.h:59
reference_wrapper.h
di::container::InFunResult
Definition
in_fun_result.h:8
di::container::detail::ForEachNFunction
Definition
for_each_n.h:12
di::container::detail::ForEachNFunction::operator()
constexpr auto operator()(Iter first, meta::TypeIdentity< SSizeType > n, F f, Proj proj={}) const -> InFunResult< Iter, F >
Definition
for_each_n.h:15
libs
di
include
di
container
algorithm
for_each_n.h
Generated by
1.13.0