Skip to content

Commit 0acf513

Browse files
committed
add + unary operator to angle
1 parent ac6443e commit 0acf513

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

include/units/Angle.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class CAngle : public Quantity<std::ratio<0>, std::ratio<0>, std::ratio<0>, std:
4343
// make CAngle able to be implicitly converted to Angle
4444
constexpr operator Angle() const { return Angle(M_PI_2 - this->value); }
4545

46-
constexpr Angle operator-() const { return Angle(M_PI_2 - this->value); }
46+
constexpr CAngle operator-() const { return CAngle(-this->value); }
47+
48+
constexpr CAngle operator+() const { return CAngle(this->value); }
4749
private:
4850
// only allow construction through literals
4951
constexpr CAngle(double value)

src/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ void initialize() {
5656
}
5757

5858
void angleTests() {
59-
static_assert(15_cDeg == 75_stDeg);
60-
static_assert(-15_cDeg == 75_stDeg);
59+
static_assert(+15_cDeg == 75_stDeg);
60+
static_assert(to_stDeg(-15_cDeg) == to_stDeg(105_stDeg));
6161
static_assert(r2i(to_stDeg(2 * 15_cDeg)) == r2i(to_stDeg(60_stDeg)));
62+
static_assert(r2i(to_stDeg(+0_cDeg)) == r2i(to_stDeg(90_stDeg)));
63+
static_assert(90_stDeg == +0_cDeg);
6264
}

0 commit comments

Comments
 (0)