std::for_each
The behavior of this template function is equivalent to:
template <class InputIterator, class Function>
Function for_each (InputIterator first, InputIterator last, Function fn);
Apply function to range
Applies function fn to each of the elements in the range [first,last).The behavior of this template function is equivalent to:
|
|
Parameters
-
first, last
-
Input iterators to the initial and final positions in a sequence. The range used is
[first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
fn
-
Unary function that accepts an element in the range as argument.
This can either be a function pointer or a move constructible function object.
Its return value, if any, is ignored.
Applies a specified function object to each element in a forward order within a range and returns the function object.

本文深入解析 C++ 标准模板库 STL 中的 for_each 函数,详细介绍了其用法和参数。该函数应用于指定范围内的每个元素,调用传入的函数对象,但不改变序列中的元素。
最低0.47元/天 解锁文章
859

被折叠的 条评论
为什么被折叠?



