std::fill_n
                Актуально для C++23.
                #include <algorithm>
                Актуально на 2024-03-20.
                Define overload #1
template<class OutputIterator, class Size, class T> constexpr OutputIterator fill_n(OutputIterator first, Size n, const T& value);
Присваивает значение "value" каждому элементу в диапазоне [first, first + n].
Example, possible implementation
Define overload #2
template<class ExecutionPolicy, class ForwardIterator, class Size, class T> ForwardIterator fill_n(ExecutionPolicy&& exec, ForwardIterator first, Size n, const T& value);
TODO
Example, possible implementation
Examples
Example 1:
#include <iostream>
#include <algorithm>
#include <vector>
int main()
{
    std::vector<int> v(10);
    std::fill_n(std::begin(v), v.size(), 42);
    for (auto it : v) {
        std::cout << it << std::endl;
    }
    return 0;
}
42 42 42 42 42 42 42 42 42 42
Changelog
See also
TODO
 This page was last modified on 2024-03-20