template <Iterator O, Sentinel<O> S, CopyConstructible F>
requires Invocable<F&> && Writable<O, result_of_t<F&()>>
O generate(O first, S last, F gen);
template <class Rng, CopyConstructible F>
requires Invocable<F&> && OutputRange<Rng, result_of_t<F&()>>
safe_iterator_t<Rng>
generate(Rng&& rng, F gen);
template <Iterator O, CopyConstructible F>
requires Invocable<F&> && Writable<O, result_of_t<F&()>>
O generate_n(O first, difference_type_t<O> n, F gen);
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 algorithm invokes the function object gen and assigns the return value of gen through all the iterators in the counted range [first,n) if n is positive, otherwise it does nothing.
Returns: last, where last is first + max(n, 0) for generate_n.
Complexity: Exactly last - first evaluations of invoke(gen) and assignments.