Name
copy_backward function template — Copies a range, starting at the end
Synopsis
template<typename BidiIter1, typename BidiIter2>
BidiIter2 copy_backward(BidiIter1 first, BidiIter1 last, BidiIter2 result);
The copy_backward
function
template does the same thing as copy
, but it works backward, starting at
the element before last
and
copying elements toward first
.
The result
iterator must point to
one past the end of the destination and is decremented before
copying each element. The return value is an iterator that points to
the first element of the destination, as shown in Figure 13-3.
The result
iterator cannot
be in the source range [first
,
last
), but other parts of the
destination range can overlap with the source.
Technical Notes
The copy_backward
function
template assigns *(result -
n) = *(last - n) for all n in the range [1, 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.