mirror of https://github.com/AxioDL/zeus.git
CVector2i: Make interface constexpr where applicable
These are just manipulating two integral values, so they can be made constexpr. While we're at it, we can also apply the noexcept specifier.
This commit is contained in:
parent
3083285c79
commit
056515b2d3
|
@ -10,26 +10,22 @@ public:
|
|||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
|
||||
constexpr CVector2i() = default;
|
||||
constexpr CVector2i() noexcept = default;
|
||||
|
||||
constexpr CVector2i(int32_t xin, int32_t yin) : x(xin), y(yin) {}
|
||||
constexpr CVector2i(int32_t xin, int32_t yin) noexcept : x(xin), y(yin) {}
|
||||
|
||||
CVector2i(const CVector2f& vec) : x(int32_t(vec.x())), y(int32_t(vec.y())) {}
|
||||
constexpr CVector2i(const CVector2f& vec) noexcept : x(int32_t(vec.x())), y(int32_t(vec.y())) {}
|
||||
|
||||
CVector2f toVec2f() const { return CVector2f(x, y); }
|
||||
constexpr CVector2f toVec2f() const noexcept { return CVector2f(x, y); }
|
||||
|
||||
CVector2i operator+(const CVector2i& val) const { return CVector2i(x + val.x, y + val.y); }
|
||||
constexpr CVector2i operator+(const CVector2i& val) const noexcept { return CVector2i(x + val.x, y + val.y); }
|
||||
constexpr CVector2i operator-(const CVector2i& val) const noexcept { return CVector2i(x - val.x, y - val.y); }
|
||||
constexpr CVector2i operator*(const CVector2i& val) const noexcept { return CVector2i(x * val.x, y * val.y); }
|
||||
constexpr CVector2i operator/(const CVector2i& val) const noexcept { return CVector2i(x / val.x, y / val.y); }
|
||||
|
||||
CVector2i operator-(const CVector2i& val) const { return CVector2i(x - val.x, y - val.y); }
|
||||
constexpr bool operator==(const CVector2i& other) const noexcept { return x == other.x && y == other.y; }
|
||||
constexpr bool operator!=(const CVector2i& other) const noexcept { return !operator==(other); }
|
||||
|
||||
CVector2i operator*(const CVector2i& val) const { return CVector2i(x * val.x, y * val.y); }
|
||||
|
||||
CVector2i operator/(const CVector2i& val) const { return CVector2i(x / val.x, y / val.y); }
|
||||
|
||||
bool operator==(const CVector2i& other) const { return x == other.x && y == other.y; }
|
||||
|
||||
bool operator!=(const CVector2i& other) const { return !operator==(other); }
|
||||
|
||||
CVector2i operator*(int32_t val) const { return CVector2i(x * val, y * val); }
|
||||
constexpr CVector2i operator*(int32_t val) const noexcept { return CVector2i(x * val, y * val); }
|
||||
};
|
||||
} // namespace zeus
|
||||
|
|
Loading…
Reference in New Issue