rippled
Loading...
Searching...
No Matches
aged_container_iterator.h
1#ifndef BEAST_CONTAINER_DETAIL_AGED_CONTAINER_ITERATOR_H_INCLUDED
2#define BEAST_CONTAINER_DETAIL_AGED_CONTAINER_ITERATOR_H_INCLUDED
3
4#include <iterator>
5#include <type_traits>
6
7namespace beast {
8
9template <bool, bool, class, class, class, class, class>
11
12namespace detail {
13
14// If Iterator is SCARY then this iterator will be as well.
15template <bool is_const, class Iterator>
17{
18public:
21 using value_type = typename std::conditional<
22 is_const,
23 typename Iterator::value_type::stashed::value_type const,
24 typename Iterator::value_type::stashed::value_type>::type;
29 using time_point = typename Iterator::value_type::stashed::time_point;
30
32
33 // Disable constructing a const_iterator from a non-const_iterator.
34 // Converting between reverse and non-reverse iterators should be explicit.
35 template <
36 bool other_is_const,
37 class OtherIterator,
38 class = typename std::enable_if<
39 (other_is_const == false || is_const == true) &&
46
47 // Disable constructing a const_iterator from a non-const_iterator.
48 template <
49 bool other_is_const,
50 class = typename std::enable_if<
51 other_is_const == false || is_const == true>::type>
57
58 // Disable assigning a const_iterator to a non-const iterator
59 template <bool other_is_const, class OtherIterator>
60 auto
63 typename std::enable_if<
64 other_is_const == false || is_const == true,
66 {
67 m_iter = other.m_iter;
68 return *this;
69 }
70
71 template <bool other_is_const, class OtherIterator>
72 bool
74 other) const
75 {
76 return m_iter == other.m_iter;
77 }
78
79 template <bool other_is_const, class OtherIterator>
80 bool
82 other) const
83 {
84 return m_iter != other.m_iter;
85 }
86
89 {
90 ++m_iter;
91 return *this;
92 }
93
96 {
97 aged_container_iterator const prev(*this);
98 ++m_iter;
99 return prev;
100 }
101
104 {
105 --m_iter;
106 return *this;
107 }
108
111 {
112 aged_container_iterator const prev(*this);
113 --m_iter;
114 return prev;
115 }
116
118 operator*() const
119 {
120 return m_iter->value;
121 }
122
123 pointer
125 {
126 return &m_iter->value;
127 }
128
129 time_point const&
130 when() const
131 {
132 return m_iter->when;
133 }
134
135private:
136 template <bool, bool, class, class, class, class, class>
138
139 template <bool, bool, class, class, class, class, class, class>
141
142 template <bool, class>
144
145 template <class OtherIterator>
146 aged_container_iterator(OtherIterator const& iter) : m_iter(iter)
147 {
148 }
149
150 Iterator const&
151 iterator() const
152 {
153 return m_iter;
154 }
155
156 Iterator m_iter;
157};
158
159} // namespace detail
160
161} // namespace beast
162
163#endif
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
Associative container where each element is also indexed by time.
Associative container where each element is also indexed by time.