Bitcoin ABC 0.30.5
P2P Digital Currency
reverse_iterator.h
Go to the documentation of this file.
1// Taken from https://gist.github.com/arvidsson/7231973
2
3#ifndef BITCOIN_REVERSE_ITERATOR_HPP
4#define BITCOIN_REVERSE_ITERATOR_HPP
5
14template <typename T> class reverse_range {
15 T &x;
16
17public:
18 explicit reverse_range(T &xin) : x(xin) {}
19
20 auto begin() const -> decltype(this->x.rbegin()) { return x.rbegin(); }
21
22 auto end() const -> decltype(this->x.rend()) { return x.rend(); }
23};
24
25template <typename T> reverse_range<T> reverse_iterate(T &x) {
26 return reverse_range<T>(x);
27}
28
29#endif // BITCOIN_REVERSE_ITERATOR_HPP
Template used for reverse iteration in C++11 range-based for loops.
reverse_range(T &xin)
auto begin() const -> decltype(this->x.rbegin())
auto end() const -> decltype(this->x.rend())
reverse_range< T > reverse_iterate(T &x)