Bitcoin Core  0.18.99
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
Template used for reverse iteration in C++11 range-based for loops.
reverse_range< T > reverse_iterate(T &x)
auto end() const -> decltype(this->m_x.rend())
auto begin() const -> decltype(this->m_x.rbegin())