std::iota
From cppreference.com
Defined in header <numeric>
|
||
template< class ForwardIterator, class T > void iota( ForwardIterator first, ForwardIterator last, T value ); |
(since C++11) | |
Fills the range [first, last)
with sequentially increasing values, starting with value
and repetitively evaluating ++value.
Equivalent operation:
*(d_first) = value; *(d_first+1) = ++value; *(d_first+2) = ++value; *(d_first+3) = ++value; ...
Parameters
first, last | - | the range of elements to fill with sequentially increasing values starting with value |
value | - | initial value to store, the expression ++value must be well-formed |
Return value
(none)
Complexity
Exactly last - first
increments and assignments.
Possible implementation
template<class ForwardIterator, class T> void iota(ForwardIterator first, ForwardIterator last, T value) { while(first != last) { *first++ = value; ++value; } } |
Notes
The function is named after the integer function ⍳ from the programming language APL. It was one of the STL components that were not included in C++98, but eventually made it into the standard library in C++11.