std::experimental::ranges:: for_each
|
template
<
InputIterator I, Sentinel
<
I
>
S,
class
Proj
=
ranges::
identity
,
IndirectUnaryInvocable
<
projected
<
I, Proj
>>
Fun
>
|
(1) | (ranges TS) |
|
template
<
InputRange R,
class
Proj
=
ranges::
identity
,
IndirectUnaryInvocable
<
projected
<
ranges::
iterator_t
<
R
>
, Proj
>>
Fun
>
|
(2) | (ranges TS) |
[
first
,
last
)
中的每个迭代器解引用后,将投影函数
proj
的调用结果作为参数,按顺序调用给定的函数对象
f
(即执行
ranges::
invoke
(
f,
ranges::
invoke
(
proj,
*
i
)
)
)。
对于两个重载版本,若迭代器类型为可变类型, f 可通过解引用迭代器修改范围内的元素。若 f 返回结果,该结果将被忽略。
与其他算法不同,for_each 不允许复制序列中的元素,即使它们是可平凡复制的。
与
std::for_each
(仅要求
MoveConstructible
)不同,这些函数要求
Fun
满足
CopyConstructible
概念。
尽管存在上述声明,算法声明的实际模板参数数量和顺序是未指定的。因此,若在调用算法时使用了显式模板参数,该程序很可能不具备可移植性。
目录参数
返回值
一个包含以下两个成员的
复杂度恰好 last - first 次对 f 和 proj 的应用。 可能实现
示例
另见
|