1 // Taken from https://gist.github.com/arvidsson/7231973
3 #ifndef BITCOIN_REVERSE_ITERATOR_HPP
4 #define BITCOIN_REVERSE_ITERATOR_HPP
7 * Template used for reverse iteration in C++11 range-based for loops.
9 * std::vector<int> v = {1, 2, 3, 4, 5};
10 * for (auto x : reverse_iterate(v))
11 * std::cout << x << " ";
20 reverse_range(T
&x
) : x(x
) {}
22 auto begin() const -> decltype(this->x
.rbegin())
27 auto end() const -> decltype(this->x
.rend())
34 reverse_range
<T
> reverse_iterate(T
&x
)
36 return reverse_range
<T
>(x
);
39 #endif // BITCOIN_REVERSE_ITERATOR_HPP