Return type : An output iterator pointing to the end of the copied range, which contains
the same elements in reverse order.
Working: The reverse_copy( ) function takes 3 parameters, two iterators 'first' & 'last' and result .
Forward iterators to the range from first to last, which contains all the elements between first and last.
Output iterator to initial position of the range where the resulting sequence is stored.
Implementation:
#include <iostream> // std::cout
#include <algorithm> // std::reverse_copy
#include <vector> // std::vector
int main () {
std::vector<int> element = {1,2,3,4,5,6,7,8,9,10};
std::vector<int> element_size (element.size());
auto it = std::reverse_copy (element.begin(), element.end(), element_size.begin());
std::cout << "element contains:";
for (int& x: element_size) std::cout << ' ' << x;
std::cout << '\n';
return 0;
}
Output:
element contains: 10 9 8 7 6 5 4 3 2 1
Comments