24 Algorithms library [algorithms]

24.6 Mutating sequence operations [alg.modifying.operations]

24.6.7 Generate [alg.generate]

template<class ForwardIterator, class Generator> constexpr 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> constexpr 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); namespace ranges { template<Iterator O, Sentinel<O> S, CopyConstructible F> requires Invocable<F&> && Writable<O, invoke_result_t<F&>> constexpr O generate(O first, S last, F gen); template<class R, CopyConstructible F> requires Invocable<F&> && OutputRange<R, invoke_result_t<F&>> constexpr safe_iterator_t<R> generate(R&& r, F gen); template<Iterator O, CopyConstructible F> requires Invocable<F&> && Writable<O, invoke_result_t<F&>> constexpr O generate_n(O first, iter_difference_t<O> n, F gen); }
Let N be for the generate_­n algorithms, and last - first for the generate algorithms.
Requires: Size shall be convertible to an integral type ([conv.integral], [class.conv]).
Effects: Assigns the result of successive evaluations of gen() through each iterator in the range [first, first + N).
Returns: first + N.
Complexity: Exactly N evaluations of gen() and assignments.