## generate_n
## Prototypetemplate <class OutputIterator, class Size, class Generator> OutputIterator generate_n(OutputIterator first, Size n, Generator gen); ## Description
## DefinitionDefined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h. ## Requirements on types-
`OutputIterator` is a model of OutputIterator. -
`Size` is an integral type (either signed or unsigned). -
`Generator` is a model of Generator. -
`Generator` 's result type is convertible to a type in`OutputIterator` 's set of value types.
## Preconditions-
`n >= 0` . -
There is enough space to hold
`n` values. That is,`[first, first+n)` is a valid range.
## ComplexityLinear. Exactly ## ExamplePrint 100 random numbers, using the C standard library function ```
generate_n(ostream_iterator<int>(cout, "\n"), 100, rand);
``` ## Notes[1] The functors ## See also |