oven::reversed

oven::reversedは範囲を逆順にするRangeアダプタです。
実装としては、範囲のイテレータを、後ろから順にイテレートするreverse_iteratorにする、
というものになっているので、逆順になった新たな範囲が生成されることはありません。

#include <iostream>
#include <iterator>
#include <vector>
#include <pstade/oven/reversed.hpp>
#include <pstade/oven/initial_values.hpp>
#include <pstade/oven/algorithm.hpp>

using namespace pstade::oven;

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

    copy(v|reversed, std::ostream_iterator<int>(std::cout, " "));
}
3 2 1 

また、reversedした範囲に対して破壊的な操作を行うこともできます。

#include <vector>
#include <boost/assert.hpp>
#include <pstade/oven/reversed.hpp>
#include <pstade/oven/front.hpp>
#include <pstade/oven/initial_values.hpp>
#include <pstade/oven/equals.hpp>

using namespace pstade::oven;

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

    v|reversed|front = 5; // 最後尾要素を書き換え

    BOOST_ASSERT(equals(v, initial_values(1, 2, 5)));
}

【参照】
pstade::oven::reversed