boost::range::reverse

References

Headers

boost::range::reverse is available by including any of the following headers:

  • boost/range/algorithm/reverse.hpp or
  • boost/range/algorithm.hpp

Examples

reverse.cpp

#include <functional>
#include <iostream>
#include <vector>
#include <boost/range/algorithm.hpp>

int main() {
    std::vector<int> vec = {1, 2, 3, 4, 5};

    // Reverses the input range and returns a reference to it.
    boost::range::reverse(vec);

    std::cout << "reversed input vector: ";
    boost::range::copy(vec, std::ostream_iterator<int>(std::cout, " "));
    std::cout << std::endl;
    return 0;
}

Output:

reversed input vector: 5 4 3 2 1

 

Boost Range for Humans

This reference is part of Boost Range for Humans. Click the link to the overview.