mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-05 20:05:59 -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;
|
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() {
|
SDL_Point* Point::Get() {
|
||||||
return point_.get();
|
return point_.get();
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,9 @@ public:
|
|||||||
Point& operator=(const Point& other);
|
Point& operator=(const Point& other);
|
||||||
Point& operator=(Point&&) noexcept = default;
|
Point& operator=(Point&&) noexcept = default;
|
||||||
|
|
||||||
|
bool operator==(const Point& other) const;
|
||||||
|
bool operator!=(const Point& other) const;
|
||||||
|
|
||||||
SDL_Point* Get();
|
SDL_Point* Get();
|
||||||
const SDL_Point* Get() const;
|
const SDL_Point* Get() const;
|
||||||
|
|
||||||
|
@ -65,6 +65,17 @@ Rect& Rect::operator=(const Rect& other) {
|
|||||||
return *this;
|
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() {
|
SDL_Rect* Rect::Get() {
|
||||||
return rect_.get();
|
return rect_.get();
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@ public:
|
|||||||
Rect& operator=(const Rect& other);
|
Rect& operator=(const Rect& other);
|
||||||
Rect& operator=(Rect&&) noexcept = default;
|
Rect& operator=(Rect&&) noexcept = default;
|
||||||
|
|
||||||
|
bool operator==(const Rect& other) const;
|
||||||
|
bool operator!=(const Rect& other) const;
|
||||||
|
|
||||||
SDL_Rect* Get();
|
SDL_Rect* Get();
|
||||||
const SDL_Rect* Get() const;
|
const SDL_Rect* Get() const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user