@specsoftdev live:.cid.8e17e9b93cabb607 specsoftdev@gmail.com
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

C++26
TODO
C++23
TODO
C++20
TODO
C++17
TODO
C++14
TODO
C++11
TODO


See also

TODO

This page was last modified on 2024-03-20