#include <algorithm>
std::reverse
template <class BidirectionalIterator> void reverse (BidirectionalIterator first, BidirectionalIterator last);
Reverse range
Reverses the order of the elements in the range [first,last)
.
The function calls iter_swap to swap the elements to their new locations.
The behavior of this function template is equivalent to:
|
|
Parameters
- first, last
- Bidirectional iterators to the initial and final positions of the sequence to be reversed. The range used is
[first,last)
, which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.
BidirectionalIterator shall point to a type for which swap is properly defined.
Return value
none
Example
|
|
Output:
myvector contains: 9 8 7 6 5 4 3 2 1 |