Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
reverse_copy
Algorithm
Summary
Reverse the order of elements in a collection while copying them to a new collecton.
Contents
Synopsis
Description
Complexity
Example
Warning
See Also
Synopsis
#include <algorithm>
template <class BidirectionalIterator, class OutputIterator>
OutputIterator reverse_copy (BidirectionalIterator first,
BidirectionalIterator last,
OutputIterator result);
Description
The reverse_copy algorithm copies the range [first, last) to the range [result, result + (last - first)) such that for any non-
negative integer i < (last - first), the following assignment takes place:
*(result + (last - first) -i) = *(first + i)
reverse_copy returns result + (last - first). The ranges [first, last) and [result, result + (last - first)) must not overlap.
Complexity
reverse_copy performs exactly (last - first) assignments.
Example
//
// reverse.cpp
//
#include <algorithm>