Skip to content

Commit 4ec716a

Browse files
committed
fix unary operator edge case
1 parent 6b01498 commit 4ec716a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/units/Angle.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ class CAngle {
5959
// make CAngle able to be implicitly converted to Angle
6060
constexpr operator Angle() const { return Angle(M_PI_2 - this->value); }
6161

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

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

6868
constexpr CAngle(double value) : value(value) {}
6969
};
7070

71+
constexpr bool operator==(Angle lhs, CAngle rhs) { return lhs == Angle(rhs); }
72+
7173
constexpr Angle rad = Angle(1.0);
7274
constexpr Angle deg = Angle(M_PI / 180);
7375
constexpr Angle rot = Angle(M_TWOPI);

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void initialize() {
4747

4848
void angleTests() {
4949
static_assert(+15_cDeg == 75_stDeg);
50-
static_assert(to_stDeg(-15_cDeg) == to_stDeg(105_stDeg));
50+
static_assert(to_stDeg(-+15_cDeg) == to_stDeg(105_stDeg));
5151
static_assert(r2i(to_stDeg(30_cDeg)) == r2i(to_stDeg(60_stDeg)));
5252
static_assert(r2i(to_stDeg(+0_cDeg)) == r2i(to_stDeg(90_stDeg)));
5353
Angle a = 2_cDeg;

0 commit comments

Comments
 (0)