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, 0)
33 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index,
34 container_id_t container_id)
35 : m_cur_node(parent, block_index, container_id), m_pos(pos), m_end(end)
41 iterator_common_base(
const iterator_common_base& other)
42 : m_cur_node(other.m_cur_node), m_pos(other.m_pos), m_end(other.m_end)
47#ifdef MDDS_MULTI_TYPE_VECTOR_DEBUG
49 throw general_error(
"Current node position should never equal the end position during node update.");
52 const typename blocks_type::value_type& blk = *m_pos;
54 m_cur_node.type = mdds::mtv::get_block_type(*blk.data);
56 m_cur_node.type = mdds::mtv::element_type_empty;
58 m_cur_node.position = blk.position;
59 m_cur_node.size = blk.size;
60 m_cur_node.data = blk.data;
81 base_iterator_type m_pos;
82 base_iterator_type m_end;
85 bool operator==(
const iterator_common_base& other)
const
87 if (m_pos != m_end && other.m_pos != other.m_end)
91 if (m_cur_node != other.m_cur_node)
94 return m_pos == other.m_pos && m_end == other.m_end;
97 iterator_common_base& operator=(
const iterator_common_base& other)
99 m_cur_node = other.m_cur_node;
105 void swap(iterator_common_base& other)
107 m_cur_node.swap(other.m_cur_node);
108 std::swap(m_pos, other.m_pos);
109 std::swap(m_end, other.m_end);
112 const node& get_node()
const
116 const base_iterator_type& get_pos()
const
120 const base_iterator_type& get_end()
const
127class iterator_base :
public iterator_common_base<Traits>
129 using parent_type =
typename Traits::parent;
130 typedef NodeUpdateFunc node_update_func;
131 typedef iterator_common_base<Traits> common_base;
133 typedef typename Traits::base_iterator base_iterator_type;
134 typedef typename common_base::size_type size_type;
136 using common_base::dec;
137 using common_base::inc;
138 using common_base::m_cur_node;
141 using common_base::get_end;
142 using common_base::get_pos;
145 typedef typename common_base::node value_type;
146 typedef value_type* pointer;
147 typedef value_type& reference;
148 typedef ptrdiff_t difference_type;
149 typedef std::bidirectional_iterator_tag iterator_category;
155 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index,
156 container_id_t container_id)
157 : common_base(pos, end, parent, block_index, container_id)
160 value_type& operator*()
165 const value_type& operator*()
const
170 value_type* operator->()
175 const value_type* operator->()
const
180 iterator_base& operator++()
182 node_update_func::inc(m_cur_node);
187 iterator_base& operator--()
190 node_update_func::dec(m_cur_node);
196class const_iterator_base :
public iterator_common_base<Traits>
198 using parent_type =
typename Traits::parent;
199 typedef NodeUpdateFunc node_update_func;
200 typedef iterator_common_base<Traits> common_base;
202 typedef typename Traits::base_iterator base_iterator_type;
203 typedef typename common_base::size_type size_type;
205 using common_base::dec;
206 using common_base::inc;
207 using common_base::m_cur_node;
210 using common_base::get_end;
211 using common_base::get_pos;
213 typedef NonConstItrBase iterator_base;
216 typedef typename common_base::node value_type;
217 typedef value_type* pointer;
218 typedef value_type& reference;
219 typedef ptrdiff_t difference_type;
220 typedef std::bidirectional_iterator_tag iterator_category;
223 const_iterator_base() : common_base()
226 const base_iterator_type& pos,
const base_iterator_type& end,
const parent_type* parent, size_type block_index,
227 container_id_t container_id)
228 : common_base(pos, end, parent, block_index, container_id)
236 other.get_pos(), other.get_end(), other.get_node().__private_data.parent,
237 other.get_node().__private_data.block_index, other.get_node().__private_data.container_id)
250 const_iterator_base& operator++()
252 node_update_func::inc(m_cur_node);
257 const_iterator_base& operator--()
260 node_update_func::dec(m_cur_node);
264 bool operator==(
const const_iterator_base& other)
const
266 return iterator_common_base<Traits>::operator==(other);