Declaration
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 function
copies all of the elements in the range
[ first, last)
to the range of size n beginning at result
, where n is the size of the range [ first, last)
, and returns the
past-the-end iterator. For copy , the source and
destination ranges may overlap if result
first.
The copy_backward function
copies all of the values in the range
[ first, last)
to the range of size n ending at result
, where n is the size of the range [ first, last)
, and returns the iterator
that contains the last element copied (i.e. the beginning of the sequence).
For copy_backward , the source
and destination ranges may overlapcopy!overlapping ranges if result
last.
Type requirements
Group Mutating sequence operations.
Time complexity Linear.
The number of type T assignment operations performed is n, where T is the type of the sequence values.
Space complexity Constant.
Mutative? Yes.
Details
Example Select here to view the source code for the example.
Implementation Select here to view source code (Copyright (C) 1994, Hewlett-Packard Company) for this algorithm.