1 #ifndef VTESTBED_BASE_MULTIPLE_ARRAY_ITERATOR_HH 2 #define VTESTBED_BASE_MULTIPLE_ARRAY_ITERATOR_HH 6 #include <initializer_list> 14 template <
class Iterator,
size_t N>
17 static_assert(N > 0,
"bad N");
20 typedef Iterator base_iterator;
26 typedef typename traits_type::value_type value_type;
27 typedef typename traits_type::difference_type difference_type;
28 typedef typename traits_type::pointer pointer;
29 typedef typename traits_type::reference reference;
32 typedef const pointer const_pointer;
33 typedef const reference const_reference;
37 Iterator _ptr =
nullptr;
42 template <
class ... Args>
45 _ptrs{ptrs...}, _ptr(_ptrs.front().first) { this->advance_empty(); }
47 template <
class ... Args>
50 _ptrs{ptrs...}, _ptr(_ptrs.back().second), _index(N) {}
62 return this->_ptr == rhs._ptr && this->_index == rhs._index;
67 return !this->operator==(rhs);
70 inline pointer operator->() {
return this->_ptr; }
71 inline const_pointer operator->()
const {
return this->_ptr; }
72 inline reference operator*() {
return *this->_ptr; }
73 inline const_reference operator*()
const {
return *this->_ptr; }
77 const auto& ptrs = this->_ptrs;
78 auto& i = this->_index;
79 auto& ptr = this->_ptr;
80 if (i != N && ++ptr == ptrs[i].second && ++i != N) {
82 this->advance_empty();
98 const auto& ptrs = this->_ptrs;
99 auto& i = this->_index;
100 auto& ptr = this->_ptr;
101 while (i != N && ptrs[i].first == ptrs[i].second) {
102 ptr = ptrs[++i].first;
112 #endif // vim:filetype=cpp