Copy-constructs a given number of elements starting from one referred to by an input iterator in the destination addressed by an output iterator.
- Template Parameters
-
InputIterator | The type of an input iterator which addresses the start of a sequence of elements to copy. |
OutputIterator | The type of an output iterator specifying the destination of the copy operation. Dereferencing of the iterator must yield an actual memory buffer where the constructed element shall reside. |
- Parameters
-
input | The input iterator associated with the beginning of the input sequence of elements to copy. |
size | The number of elements in the input sequence to copy. |
output | The output iterator. The expression *output must yield a reference to the actual buffer, in an uninitialized state, where the corresponding element of the output sequence is copy-constructed. |
- Returns
- The output iterator after the copy operation, i.e. the iterator associated with the position in the destination after the last copied element, or
output
, if size
is zero.
- Exceptions
-
Any | exception that originates from copy-construction of the sequence elements. |
The function behaves exactly like the standard std::copy_n except that construct_copy_n
performs copy-construction in uninitialized memory space rather than assignment of sequence elements. Also, the input and output sequences must not overlap in memory.
The operation does not invoke any destructors or assignment operators for elements of the copied sequences, i.e. the function copies elements into uninitialized memory buffers discarding its prior contents. To replace existing elements with copy-assignment, use the copy_n function.