mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Add Point and Rect comparison operators
This commit is contained in:
parent
802322ef1b
commit
0365329dc0
@ -59,6 +59,16 @@ Point& Point::operator=(const Point& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Point::operator==(const Point& other) const {
|
||||
if (!point_ || !other.point_)
|
||||
return point_ == other.point_; // true only if both null
|
||||
return point_->x == other.point_->x && point_->y == other.point_->y;
|
||||
}
|
||||
|
||||
bool Point::operator!=(const Point& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
SDL_Point* Point::Get() {
|
||||
return point_.get();
|
||||
}
|
||||
|
@ -56,6 +56,9 @@ public:
|
||||
Point& operator=(const Point& other);
|
||||
Point& operator=(Point&&) noexcept = default;
|
||||
|
||||
bool operator==(const Point& other) const;
|
||||
bool operator!=(const Point& other) const;
|
||||
|
||||
SDL_Point* Get();
|
||||
const SDL_Point* Get() const;
|
||||
|
||||
|
@ -65,6 +65,17 @@ Rect& Rect::operator=(const Rect& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Rect::operator==(const Rect& other) const {
|
||||
if (!rect_ || !other.rect_)
|
||||
return rect_ == other.rect_; // true only if both null
|
||||
return rect_->x == other.rect_->x && rect_->y == other.rect_->y &&
|
||||
rect_->w == other.rect_->w && rect_->h == other.rect_->h;
|
||||
}
|
||||
|
||||
bool Rect::operator!=(const Rect& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
SDL_Rect* Rect::Get() {
|
||||
return rect_.get();
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ public:
|
||||
Rect& operator=(const Rect& other);
|
||||
Rect& operator=(Rect&&) noexcept = default;
|
||||
|
||||
bool operator==(const Rect& other) const;
|
||||
bool operator!=(const Rect& other) const;
|
||||
|
||||
SDL_Rect* Get();
|
||||
const SDL_Rect* Get() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user