The behavior of this function template is equivalent to:
| 1 2 3 4 5 |
|
Parameters
- first
- Output iterators to the initial positions in a sequence of at least n elements.
- n
- Number of elements to set value to.
Its type is an integral type or some other type convertible to it. - gen
- Generator function that takes no arguments and returns some value to be stored as element value. This can either be a pointer to a function or an object whose class overloads operator().
Return value
noneExample
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
A possible output:
myarray contains: 1 2 3 4 5 6 7 8 9 |
Complexity
Linear: Invokes gen and assigns that value, n times.See also
| generate | Generate values for range with function (function template) |
| fill_n | Fill sequence with value (function template) |
| for_each | Apply function to range (template function) |
