Bitcoin ABC  0.22.13
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 
14 template <typename T> class reverse_range {
15  T &x;
16 
17 public:
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 
25 template <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 > reverse_iterate(T &x)
reverse_range(T &xin)
auto begin() const -> decltype(this->x.rbegin())
auto end() const -> decltype(this->x.rend())