Name
reverse_copy function template — Copies a range in reverse order
Synopsis
template<typename BidiIter, typename OutIter>
OutIter reverse_copy(BidiIter first, BidiIter last, OutIter result);
The reverse_copy
function
template copies items in reverse order from the range [first
, last
) to the range that starts at result
. In other words, *(last
- 1)
is first copied to *result
, then *(last
- 2)
is copied to *(result
+
1)
,
and so on. The return value is an iterator that points to one past
the end of the result range. The source and result ranges must not
overlap. Figure 13-15
shows an example of reversing a range.
Technical Notes
The reverse_copy
function
template assigns *(result +
n) = *(last - n - 1) for all n in [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.