Let operator++() return a reference.

This commit is contained in:
Mark de Wever 2011-09-28 19:21:12 +00:00
parent 38243fa4bf
commit b99c907f5c
2 changed files with 4 additions and 2 deletions

View file

@ -347,7 +347,7 @@ const map_location display::pixel_position_to_hex(int x, int y) const
return map_location(x_base + x_modifier - offset, y_base + y_modifier - offset);
}
void display::rect_of_hexes::iterator::operator++()
display::rect_of_hexes::iterator& display::rect_of_hexes::iterator::operator++()
{
if (loc_.y < rect_.bottom[loc_.x & 1])
++loc_.y;
@ -355,6 +355,8 @@ void display::rect_of_hexes::iterator::operator++()
++loc_.x;
loc_.y = rect_.top[loc_.x & 1];
}
return *this;
}
// begin is top left, and end is after bottom right

View file

@ -207,7 +207,7 @@ public:
: loc_(loc), rect_(rect){};
/** increment y first, then when reaching bottom, increment x */
void operator++();
iterator& operator++();
bool operator==(const iterator &that) const { return that.loc_ == loc_; }
bool operator!=(const iterator &that) const { return that.loc_ != loc_; }
const map_location& operator*() const {return loc_;};