28 Algorithms library [algorithms]

28.6 Mutating sequence operations [alg.modifying.operations]

28.6.7 Generate [alg.generate]

template<class ForwardIterator, class Generator> void generate(ForwardIterator first, ForwardIterator last, Generator gen); template<class ExecutionPolicy, class ForwardIterator, class Generator> void generate(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, Generator gen); template<class OutputIterator, class Size, class Generator> OutputIterator generate_n(OutputIterator first, Size n, Generator gen); template<class ExecutionPolicy, class ForwardIterator, class Size, class Generator> ForwardIterator generate_n(ExecutionPolicy&& exec, ForwardIterator first, Size n, Generator gen);
Requires: gen takes no arguments, Size shall be convertible to an integral type ([conv.integral], [class.conv]).
Effects: The generate algorithms invoke the function object gen and assign the return value of gen through all the iterators in the range [first, last).
The generate_­n algorithms invoke the function object gen and assign the return value of gen through all the iterators in the range [first, first + n) if n is positive, otherwise they do nothing.
Returns: generate_­n returns first + n for non-negative values of n and first for negative values.
Complexity: Exactly last - first, n, or 0 invocations of gen and assignments, respectively.