oven::rotated

oven::rotatedは、範囲の要素を回転するstd::rotateのRangeアダプタ版です。

#include <iostream>
#include <vector>
#include <boost/utility.hpp>
#include <pstade/oven/rotated.hpp>
#include <pstade/oven/io.hpp>
#include <pstade/oven/initial_values.hpp>

using namespace pstade::oven;

class distance_n {
    int d_;

public:
    explicit distance_n(int d) : d_(d) {}

    template <class R>
    typename boost::range_iterator<R>::type
        operator()(R& r) const
    {
        return boost::next(boost::begin(r), d_);
    }
};

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

    std::cout << (v|rotated(distance_n(3))) << std::endl;
}
{4,5,1,2,3}

【参照】
pstade::oven::rotated