Skip to content

Commit

Permalink
fix unary operator edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Dec 29, 2024
1 parent 6b01498 commit 4ec716a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/units/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ class CAngle {
// make CAngle able to be implicitly converted to Angle
constexpr operator Angle() const { return Angle(M_PI_2 - this->value); }

constexpr Angle operator-() const { return CAngle(-this->value); }
constexpr CAngle operator-() const { return CAngle(-this->value); }

constexpr Angle operator+() const { return CAngle(this->value); }
constexpr CAngle operator+() const { return CAngle(this->value); }
private:
const double value;

constexpr CAngle(double value) : value(value) {}
};

constexpr bool operator==(Angle lhs, CAngle rhs) { return lhs == Angle(rhs); }

constexpr Angle rad = Angle(1.0);
constexpr Angle deg = Angle(M_PI / 180);
constexpr Angle rot = Angle(M_TWOPI);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void initialize() {

void angleTests() {
static_assert(+15_cDeg == 75_stDeg);
static_assert(to_stDeg(-15_cDeg) == to_stDeg(105_stDeg));
static_assert(to_stDeg(-+15_cDeg) == to_stDeg(105_stDeg));
static_assert(r2i(to_stDeg(30_cDeg)) == r2i(to_stDeg(60_stDeg)));
static_assert(r2i(to_stDeg(+0_cDeg)) == r2i(to_stDeg(90_stDeg)));
Angle a = 2_cDeg;
Expand Down

0 comments on commit 4ec716a

Please sign in to comment.