@specsoftdev live:.cid.8e17e9b93cabb607 specsoftdev@gmail.com
std::iota
Актуально для C++23.

#include <algorithm>
Актуально на 2024-02-16.


Define overload #1
template<class ForwardIterator, class T>
constexpr
void iota(ForwardIterator first, ForwardIterator last, T value);

Заполнит последовательность [first, last] значением value, инкрементируя его после каждого присваивания.
Example, possible implementation

Examples


Example 1:
#include <iostream>
#include <numeric>
#include <vector>

int main()
{
    std::vector<int> v;
    v.resize(5, 0);
    std::iota(std::begin(v), std::end(v), 0);

    for (auto el : v)
        std::cout << el << std::endl;

    return 0;
}

0
1
2
3
4



Changelog



See also

TODO

This page was last modified on 2024-02-16