Unlike algorithm copy, uninitialized_copy constructs the objects at destination, instead of just copying them. This allows to obtain fully constructed copies of the elements into a range of uninitialized memory, such as a memory block obtained by a call to get_temporary_buffer or malloc.
The behavior of this function template is equivalent to:
| 1 2 3 4 5 6 7 8 |
|
Parameters
- first, last
- Input iterators to the initial and final positions in a sequence to be copied. The range used is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
- result
- Output iterator to the initial position in the uninitialized destination sequence. This shall not point to any element in the range [first,last).
Return value
An iterator to the last element of the destination sequence where elements have been copied. [standard is ambiguous]Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
Output:
one two three |
Complexity
Linear: constructs (copy construction) as many objects as the distance between first and last.See also
| copy | Copy range of elements (function template) |
| uninitialized_fill | Fill block of memory (function template) |
| get_temporary_buffer | Get block of temporary memory (function template) |
