Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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.
auto begin() const -> decltype(this->x.rbegin())
auto end() const -> decltype(this->x.rend())
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
reverse_range< T > reverse_iterate(T &x)