Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
copy, copy_backward
Algorithm
Summary
Copies a range of elements
Contents
Synopsis
Description
Complexity
Example
Warning
Synopsis
#include <algorithm>
template <class InputIterator, class OutputIterator>
OutputIterator copy(InputIterator first, InputIterator last,
OutputIterator result);
template <class BidirectionalIterator1, class BidirectionalIterator2>
BidirectionalIterator2 copy_backward(BidirectionalIterator1 first,
BidirectionalIterator1 last,
BidirectionalIterator2 result);
Description
The copy algorithm copies values from the range specified by [first , last) to the range that specified by
[result, result + (last - first)). copy can be used to copy values from one container to another, or to copy
values from one location in a container to another location in the same container, as long as result is
not within the range [first-last). copy returns result + (last - first). For each non-negative integer n <
(last - first), copy assigns *(first + n) to *(result + n). The result of copy is undefined if result is in the
range [first, last).