Name
copy function template — Copies every item in a range
Synopsis
template<typename InIter, typename OutIter>
OutIter copy(InIter first, InIter last, OutIter result);
The copy
function template
copies items from [first
,
last
) to the output iterator
starting at result
. You must
ensure that the output sequence has enough room for last
- first
items. The return value is the value
of the result
iterator after
copying all the items, as shown in Figure 13-2.
The result
iterator cannot
be in the source range [first
,
last
), but other parts of the
destination range can overlap with the source.
See Example 13-2
(under generate
).
Technical Notes
The copy
function template
assigns *(result + n) = *(first + n) for all n in the range [0, last - first).
Complexity is linear: exactly last - first assignments are performed.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.