43class iterator_common_base
46 typedef typename Traits::parent parent_type;
47 typedef typename Traits::blocks blocks_type;
48 typedef typename Traits::base_iterator base_iterator_type;
50 typedef typename parent_type::size_type size_type;
53 iterator_common_base() : m_cur_node(
nullptr, 0)
57 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
58 : m_cur_node(parent, block_index), m_pos(pos), m_end(end)
64 iterator_common_base(
const iterator_common_base& other)
65 : m_cur_node(other.m_cur_node), m_pos(other.m_pos), m_end(other.m_end)
70#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
72 throw general_error(
"Current node position should never equal the end position during node update.");
75 const typename blocks_type::value_type& blk = *m_pos;
77 m_cur_node.type = mdds::mtv::get_block_type(*blk.data);
79 m_cur_node.type = mdds::mtv::element_type_empty;
81 m_cur_node.position = blk.position;
82 m_cur_node.size = blk.size;
83 m_cur_node.data = blk.data;
104 base_iterator_type m_pos;
105 base_iterator_type m_end;
108 bool operator==(
const iterator_common_base& other)
const
110 if (m_pos != m_end && other.m_pos != other.m_end)
114 if (m_cur_node != other.m_cur_node)
117 return m_pos == other.m_pos && m_end == other.m_end;
120 bool operator!=(
const iterator_common_base& other)
const
122 return !operator==(other);
125 iterator_common_base& operator=(
const iterator_common_base& other)
127 m_cur_node = other.m_cur_node;
133 void swap(iterator_common_base& other)
135 m_cur_node.swap(other.m_cur_node);
136 std::swap(m_pos, other.m_pos);
137 std::swap(m_end, other.m_end);
140 const node& get_node()
const
144 const base_iterator_type& get_pos()
const
148 const base_iterator_type& get_end()
const
155class iterator_base :
public iterator_common_base<Traits>
157 using parent_type =
typename Traits::parent;
158 typedef NodeUpdateFunc node_update_func;
159 typedef iterator_common_base<Traits> common_base;
161 typedef typename Traits::base_iterator base_iterator_type;
162 typedef typename common_base::size_type size_type;
164 using common_base::dec;
165 using common_base::inc;
166 using common_base::m_cur_node;
169 using common_base::get_end;
170 using common_base::get_pos;
173 typedef typename common_base::node value_type;
174 typedef value_type* pointer;
175 typedef value_type& reference;
176 typedef ptrdiff_t difference_type;
177 typedef std::bidirectional_iterator_tag iterator_category;
183 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
184 : common_base(pos, end, parent, block_index)
187 value_type& operator*()
192 const value_type& operator*()
const
197 value_type* operator->()
202 const value_type* operator->()
const
207 iterator_base& operator++()
209 node_update_func::inc(m_cur_node);
214 iterator_base& operator--()
217 node_update_func::dec(m_cur_node);
223class const_iterator_base :
public iterator_common_base<Traits>
225 using parent_type =
typename Traits::parent;
226 typedef NodeUpdateFunc node_update_func;
227 typedef iterator_common_base<Traits> common_base;
229 typedef typename Traits::base_iterator base_iterator_type;
230 typedef typename common_base::size_type size_type;
232 using common_base::dec;
233 using common_base::inc;
234 using common_base::m_cur_node;
237 using common_base::get_end;
238 using common_base::get_pos;
240 typedef NonConstItrBase iterator_base;
243 typedef typename common_base::node value_type;
244 typedef value_type* pointer;
245 typedef value_type& reference;
246 typedef ptrdiff_t difference_type;
247 typedef std::bidirectional_iterator_tag iterator_category;
250 const_iterator_base() : common_base()
253 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index)
254 : common_base(pos, end, parent, block_index)
262 other.get_pos(), other.get_end(), other.get_node().__private_data.parent,
263 other.get_node().__private_data.block_index)
276 const_iterator_base& operator++()
278 node_update_func::inc(m_cur_node);
283 const_iterator_base& operator--()
286 node_update_func::dec(m_cur_node);
290 bool operator==(
const const_iterator_base& other)
const
292 return iterator_common_base<Traits>::operator==(other);
295 bool operator!=(
const const_iterator_base& other)
const
297 return iterator_common_base<Traits>::operator!=(other);