Bitcoin ABC  0.24.10
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
reverse_range::end
auto end() const -> decltype(this->x.rend())
Definition: reverse_iterator.h:22
reverse_range::reverse_range
reverse_range(T &xin)
Definition: reverse_iterator.h:18
reverse_range::begin
auto begin() const -> decltype(this->x.rbegin())
Definition: reverse_iterator.h:20
reverse_range::x
T & x
Definition: reverse_iterator.h:15
reverse_range
Template used for reverse iteration in C++11 range-based for loops.
Definition: reverse_iterator.h:14
reverse_iterate
reverse_range< T > reverse_iterate(T &x)
Definition: reverse_iterator.h:25