19class iterator_common_base
22 typedef typename Traits::parent parent_type;
23 typedef typename Traits::blocks blocks_type;
24 typedef typename Traits::base_iterator base_iterator_type;
26 typedef typename parent_type::size_type size_type;
29 iterator_common_base() : m_cur_node(
nullptr, 0)
33 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
34 : m_cur_node(parent, block_index), m_pos(pos), m_end(end)
40 iterator_common_base(
const iterator_common_base& other)
41 : m_cur_node(other.m_cur_node), m_pos(other.m_pos), m_end(other.m_end)
46#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
48 throw general_error(
"Current node position should never equal the end position during node update.");
51 const typename blocks_type::value_type& blk = *m_pos;
53 m_cur_node.type = mdds::mtv::get_block_type(*blk.data);
55 m_cur_node.type = mdds::mtv::element_type_empty;
57 m_cur_node.position = blk.position;
58 m_cur_node.size = blk.size;
59 m_cur_node.data = blk.data;
80 base_iterator_type m_pos;
81 base_iterator_type m_end;
84 bool operator==(
const iterator_common_base& other)
const
86 if (m_pos != m_end && other.m_pos != other.m_end)
90 if (m_cur_node != other.m_cur_node)
93 return m_pos == other.m_pos && m_end == other.m_end;
96 bool operator!=(
const iterator_common_base& other)
const
98 return !operator==(other);
101 iterator_common_base& operator=(
const iterator_common_base& other)
103 m_cur_node = other.m_cur_node;
109 void swap(iterator_common_base& other)
111 m_cur_node.swap(other.m_cur_node);
112 std::swap(m_pos, other.m_pos);
113 std::swap(m_end, other.m_end);
116 const node& get_node()
const
120 const base_iterator_type& get_pos()
const
124 const base_iterator_type& get_end()
const
131class iterator_base :
public iterator_common_base<Traits>
133 using parent_type =
typename Traits::parent;
134 typedef NodeUpdateFunc node_update_func;
135 typedef iterator_common_base<Traits> common_base;
137 typedef typename Traits::base_iterator base_iterator_type;
138 typedef typename common_base::size_type size_type;
140 using common_base::dec;
141 using common_base::inc;
142 using common_base::m_cur_node;
145 using common_base::get_end;
146 using common_base::get_pos;
149 typedef typename common_base::node value_type;
150 typedef value_type* pointer;
151 typedef value_type& reference;
152 typedef ptrdiff_t difference_type;
153 typedef std::bidirectional_iterator_tag iterator_category;
159 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
160 : common_base(pos, end, parent, block_index)
163 value_type& operator*()
168 const value_type& operator*()
const
173 value_type* operator->()
178 const value_type* operator->()
const
183 iterator_base& operator++()
185 node_update_func::inc(m_cur_node);
190 iterator_base& operator--()
193 node_update_func::dec(m_cur_node);
199class const_iterator_base :
public iterator_common_base<Traits>
201 using parent_type =
typename Traits::parent;
202 typedef NodeUpdateFunc node_update_func;
203 typedef iterator_common_base<Traits> common_base;
205 typedef typename Traits::base_iterator base_iterator_type;
206 typedef typename common_base::size_type size_type;
208 using common_base::dec;
209 using common_base::inc;
210 using common_base::m_cur_node;
213 using common_base::get_end;
214 using common_base::get_pos;
216 typedef NonConstItrBase iterator_base;
219 typedef typename common_base::node value_type;
220 typedef value_type* pointer;
221 typedef value_type& reference;
222 typedef ptrdiff_t difference_type;
223 typedef std::bidirectional_iterator_tag iterator_category;
226 const_iterator_base() : common_base()
229 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
230 : common_base(pos, end, parent, block_index)
238 other.get_pos(), other.get_end(), other.get_node().__private_data.parent,
239 other.get_node().__private_data.block_index)
252 const_iterator_base& operator++()
254 node_update_func::inc(m_cur_node);
259 const_iterator_base& operator--()
262 node_update_func::dec(m_cur_node);
266 bool operator==(
const const_iterator_base& other)
const
268 return iterator_common_base<Traits>::operator==(other);
271 bool operator!=(
const const_iterator_base& other)
const
273 return iterator_common_base<Traits>::operator!=(other);