[nostalgia/common] Add constexpr and noexcept where appropriate

This commit is contained in:
2021-04-23 23:24:42 -05:00
parent 4518288745
commit 2dc9ce4015
4 changed files with 108 additions and 100 deletions
+7 -7
View File
@@ -9,34 +9,34 @@
namespace nostalgia::common {
Bounds::Bounds(int x, int y, int w, int h) {
Bounds::Bounds(int x, int y, int w, int h) noexcept {
this->x = x;
this->y = y;
this->width = w;
this->height = h;
}
bool Bounds::intersects(Bounds o) const {
bool Bounds::intersects(const Bounds &o) const noexcept {
return o.x2() >= x && x2() >= o.x && o.y2() >= y && y2() >= o.y;
}
bool Bounds::contains(int x, int y) const {
bool Bounds::contains(int x, int y) const noexcept {
return x >= this->x && y >= this->y && x <= x2() && y <= y2();
}
int Bounds::x2() const {
int Bounds::x2() const noexcept {
return x + width;
}
int Bounds::y2() const {
int Bounds::y2() const noexcept {
return y + height;
}
Point Bounds::pt1() {
Point Bounds::pt1() const noexcept {
return Point(x, y);
}
Point Bounds::pt2() {
Point Bounds::pt2() const noexcept {
return Point(x2(), y2());
}