rippled
Loading...
Searching...
No Matches
aged_container_iterator.h
1#pragma once
2
3#include <iterator>
4#include <type_traits>
5
6namespace beast {
7
8template <bool, bool, class, class, class, class, class>
10
11namespace detail {
12
13// If Iterator is SCARY then this iterator will be as well.
14template <bool is_const, class Iterator>
16{
17public:
19 using value_type = typename std::conditional<
20 is_const,
21 typename Iterator::value_type::stashed::value_type const,
22 typename Iterator::value_type::stashed::value_type>::type;
26 using time_point = typename Iterator::value_type::stashed::time_point;
27
29
30 // Disable constructing a const_iterator from a non-const_iterator.
31 // Converting between reverse and non-reverse iterators should be explicit.
32 template <
33 bool other_is_const,
34 class OtherIterator,
35 class = typename std::enable_if<
36 (other_is_const == false || is_const == true) &&
42
43 // Disable constructing a const_iterator from a non-const_iterator.
44 template <bool other_is_const, class = typename std::enable_if<other_is_const == false || is_const == true>::type>
48
49 // Disable assigning a const_iterator to a non-const iterator
50 template <bool other_is_const, class OtherIterator>
51 auto
58
59 template <bool other_is_const, class OtherIterator>
60 bool
62 {
63 return m_iter == other.m_iter;
64 }
65
66 template <bool other_is_const, class OtherIterator>
67 bool
69 {
70 return m_iter != other.m_iter;
71 }
72
75 {
76 ++m_iter;
77 return *this;
78 }
79
82 {
83 aged_container_iterator const prev(*this);
84 ++m_iter;
85 return prev;
86 }
87
90 {
91 --m_iter;
92 return *this;
93 }
94
97 {
98 aged_container_iterator const prev(*this);
99 --m_iter;
100 return prev;
101 }
102
104 operator*() const
105 {
106 return m_iter->value;
107 }
108
109 pointer
111 {
112 return &m_iter->value;
113 }
114
115 time_point const&
116 when() const
117 {
118 return m_iter->when;
119 }
120
121private:
122 template <bool, bool, class, class, class, class, class>
124
125 template <bool, bool, class, class, class, class, class, class>
127
128 template <bool, class>
130
131 template <class OtherIterator>
132 aged_container_iterator(OtherIterator const& iter) : m_iter(iter)
133 {
134 }
135
136 Iterator const&
137 iterator() const
138 {
139 return m_iter;
140 }
141
142 Iterator m_iter;
143};
144
145} // namespace detail
146
147} // namespace beast
typename std::iterator_traits< Iterator >::iterator_category iterator_category
typename std::iterator_traits< Iterator >::difference_type difference_type
bool operator!=(aged_container_iterator< other_is_const, OtherIterator > const &other) const
bool operator==(aged_container_iterator< other_is_const, OtherIterator > const &other) const
typename Iterator::value_type::stashed::time_point time_point
typename std::conditional< is_const, typename Iterator::value_type::stashed::value_type const, typename Iterator::value_type::stashed::value_type >::type value_type
aged_container_iterator(aged_container_iterator< other_is_const, OtherIterator > const &other)
aged_container_iterator(aged_container_iterator< other_is_const, Iterator > const &other)
auto operator=(aged_container_iterator< other_is_const, OtherIterator > const &other) -> typename std::enable_if< other_is_const==false||is_const==true, aged_container_iterator & >::type