1 // Taken from https://gist.github.com/arvidsson/7231973
3 #ifndef BITCOIN_REVERSE_ITERATOR_H
4 #define BITCOIN_REVERSE_ITERATOR_H
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 explicit reverse_range(T
&x
) : m_x(x
) {}
22 auto begin() const -> decltype(this->m_x
.rbegin())
27 auto end() const -> decltype(this->m_x
.rend())
34 reverse_range
<T
> reverse_iterate(T
&x
)
36 return reverse_range
<T
>(x
);
39 #endif // BITCOIN_REVERSE_ITERATOR_H