function template
<numeric>
std::iotatemplate <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val);
Store increasing sequence
Assigns to every element in the range[first,last)
successive values of val, as if incremented with ++val
after each element is written.
The behavior of this function template is equivalent to:
1
2
3
4
5
6
7
8
9
template <class ForwardIterator, class T>
void iota (ForwardIterator first, ForwardIterator last, T val)
{
while (first!=last) {
*first = val;
++first;
++val;
}
}
[first,last)
, which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// iota example
#include <iostream> // std::cout
#include <numeric> // std::iota
int main () {
int numbers[10];
std::iota (numbers,numbers+10,100);
std::cout << "numbers:";
for (int& i:numbers) std::cout << ' ' << i;
std::cout << '\n';
return 0;
}
numbers: 100 101 102 103 104 105 106 107 108 109
[first,last)
are modified (each element is modified exactly once).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4