Bitcoin Core  21.99.0
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_H
4 #define BITCOIN_REVERSE_ITERATOR_H
5 
14 template <typename T>
16 {
17  T &m_x;
18 
19 public:
20  explicit reverse_range(T &x) : m_x(x) {}
21 
22  auto begin() const -> decltype(this->m_x.rbegin())
23  {
24  return m_x.rbegin();
25  }
26 
27  auto end() const -> decltype(this->m_x.rend())
28  {
29  return m_x.rend();
30  }
31 };
32 
33 template <typename T>
35 {
36  return reverse_range<T>(x);
37 }
38 
39 #endif // BITCOIN_REVERSE_ITERATOR_H
reverse_range::m_x
T & m_x
Definition: reverse_iterator.h:17
reverse_range::begin
auto begin() const -> decltype(this->m_x.rbegin())
Definition: reverse_iterator.h:22
reverse_range::end
auto end() const -> decltype(this->m_x.rend())
Definition: reverse_iterator.h:27
reverse_range
Template used for reverse iteration in C++11 range-based for loops.
Definition: reverse_iterator.h:15
reverse_iterate
reverse_range< T > reverse_iterate(T &x)
Definition: reverse_iterator.h:34
reverse_range::reverse_range
reverse_range(T &x)
Definition: reverse_iterator.h:20