25class layered_population<I>::base_iterator
28 using iterator_category = std::forward_iterator_tag;
30 using pointer = value_type *;
31 using const_pointer =
const value_type *;
32 using reference = value_type &;
33 using const_reference =
const value_type &;
34 using difference_type = std::ptrdiff_t;
36 using ptr = std::conditional_t<is_const, const_pointer, pointer>;
37 using ref = std::conditional_t<is_const, const_reference, reference>;
38 using pop = std::conditional_t<is_const,
39 const layered_population, layered_population>;
40 using itr = std::conditional_t<is_const,
41 typename pop::layer_const_iter,
42 typename pop::layer_iter>;
46 base_iterator()
noexcept =
default;
52 const auto layers(p.range_of_layers());
55 layer_ = begin ? layers.begin() : end_;
56 pos_.layer_index = begin ? 0 : p.layers();
68 Expects(layer_ != end_);
70 if (++pos_.individual_coord >= layer_->size())
74 pos_.individual_coord = 0;
79 assert((layer_ != end_ && pos_.individual_coord < layer_->size())
80 || (layer_ == end_ && pos_.individual_coord == 0));
89 base_iterator tmp(*
this);
102 [[nodiscard]]
bool operator==(
const base_iterator &other)
const noexcept
104 return layer_ == other.layer_
105 && pos_.individual_coord == other.pos_.individual_coord;
108 [[nodiscard]] std::size_t uid() const noexcept
110 Expects(layer_ != end_);
111 return layer_->uid();
116 Expects(layer_ != end_);
117 Expects(pos_.individual_coord < layer_->size());
124 Expects(layer_ != end_);
125 Expects(pos_.individual_coord < layer_->size());
126 return (*layer_)[pos_.individual_coord];
137 out <<
'[' << i.pos_.layer_index <<
',' << i.pos_.individual_coord <<
']';
142 void skip_empty_layers() noexcept
144 while (layer_ != end_ && layer_->empty())
153 layered_population<I>::coord pos_ {0, 0};