template <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val);
[first,last)
++val
123456789
template <class ForwardIterator, class T> void iota (ForwardIterator first, ForwardIterator last, T val) { while (first!=last) { *first = val; ++first; ++val; } }
123456789101112131415
// 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