** Declaration**

template <class BidirectionalIterator> inline void reverse(BidirectionalIterator first, BidirectionalIterator last); template <class BidirectionalIterator, class OutputIterator> OutputIterator reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);

** Description** The function
` reverse`
reverses the order of the elements in
range [` first`, ` last`)
.

The function ` reverse_copy`
reverses the order of the elements in range
[` first`, ` last`)
, placing the result in the range of size * n* beginning at ` result`
, where * n* is the size of the range [` first`, ` last`)
,
and returns the location * l* that is the past-the-end
iteratoriterator!past-the-end for the resulting sequence.

** Type requirements**

- For the function
`reverse`,`BidirectionalIterator`must be at least a regular bidirectional iterator . For the function`reverse_copy`,`BidirectionalIterator`must be at least a readable bidirectional iterator . -
`OutputIterator`must be at least an output iterator .

** Group** Mutating sequence operations.

** Time complexity** Linear.

element exchanges are performed, where * n* is the size of the range [` first`, ` last`)
.

For ` reverse_copy` , exactly
* n* assignment operations are performed, where * n* is the size of the range [` first`, ` last`)
.

** Space complexity** Constant.

** Mutative?** Yes.

** Details** For the sequence in the range
[` first`, ` last`)
, the resulting sequence is
.

** 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.

Mon May 13 04:03:40 EDT 1996