@@ -41,39 +41,25 @@ template <> struct LookupName<Quantity<std::ratio<0>, std::ratio<0>, std::ratio<
4141 * because the constructor is private. However, you can do
4242 * Angle angle = 2_cDeg
4343 */
44- class CAngle : public Quantity <std::ratio<0 >, std::ratio<0 >, std::ratio<0 >, std::ratio<0 >, std::ratio<1 >, std::ratio<0 >,
45- std::ratio<0 >, std::ratio<0 >> {
44+ class CAngle {
4645 // make string literals friends, so they have access to the constructor
4746 friend constexpr CAngle operator " " _cRad(long double value);
4847 friend constexpr CAngle operator " " _cRad(unsigned long long value);
4948 friend constexpr CAngle operator " " _cDeg(long double value);
5049 friend constexpr CAngle operator " " _cDeg(unsigned long long value);
5150 friend constexpr CAngle operator " " _cRot(long double value);
5251 friend constexpr CAngle operator " " _cRot(unsigned long long value);
53- friend constexpr CAngle operator *(double multiple, CAngle quantity);
54- friend constexpr CAngle operator *(CAngle quantity, double multiple);
55- friend constexpr CAngle operator /(double multiple, CAngle quantity);
56- friend constexpr CAngle operator /(CAngle quantity, double multiple);
5752 public:
5853 // make CAngle able to be implicitly converted to Angle
5954 constexpr operator Angle () const { return Angle (M_PI_2 - this ->value ); }
6055
61- constexpr Angle operator -(Angle other ) const { return Angle (* this ) - other ; }
56+ constexpr Angle operator -() const { return CAngle (- this -> value ) ; }
6257
63- constexpr CAngle operator -() const { return CAngle (-this ->value ); }
64-
65- constexpr Angle operator +(Angle other) const { return Angle (*this ) + other; }
66-
67- constexpr CAngle operator +() const { return CAngle (this ->value ); }
58+ constexpr Angle operator +() const { return CAngle (this ->value ); }
6859 private:
69- // only allow construction through literals
70- constexpr CAngle (double value)
71- : Quantity<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>,
72- std::ratio<0>, std::ratio<0>>(value) {}
60+ const double value;
7361
74- constexpr CAngle (Angle value)
75- : Quantity<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>,
76- std::ratio<0>, std::ratio<0>>(value) {}
62+ constexpr CAngle (double value) : value(value) {}
7763};
7864
7965constexpr bool operator ==(Angle lhs, CAngle rhs) { return lhs == Angle (rhs); }
@@ -83,27 +69,6 @@ inline std::ostream& operator<<(std::ostream& os, const Angle& quantity) {
8369 return os;
8470}
8571
86- constexpr Angle operator +(Angle lhs, CAngle rhs) { return lhs + Angle (rhs); }
87-
88- constexpr Angle operator -(Angle lhs, CAngle rhs) { return lhs - Angle (rhs); }
89-
90- constexpr CAngle operator *(double multiple, CAngle quantity) { return CAngle (multiple * quantity.internal ()); }
91-
92- constexpr CAngle operator *(CAngle quantity, double multiple) { return CAngle (multiple * quantity.internal ()); }
93-
94- constexpr CAngle operator /(CAngle quantity, double multiple) { return CAngle (quantity.internal () / multiple); }
95-
96- namespace units {
97- template <typename T>
98- concept isAngle = std::same_as<T, CAngle> || std::same_as<T, Angle> ||
99- std::same_as<T, Quantity<std::ratio<0 >, std::ratio<0 >, std::ratio<0 >, std::ratio<0 >, std::ratio<1 >,
100- std::ratio<0 >, std::ratio<0 >, std::ratio<0 >>>;
101-
102- template <isAngle Q, isAngle R, isAngle S> constexpr Angle clamp (Q lhs, R lo, S hi) {
103- return Angle (std::clamp (lhs.internal (), lo.internal (), hi.internal ()));
104- }
105- } // namespace units
106-
10772constexpr Angle rad = Angle(1.0 );
10873constexpr Angle deg = Angle(M_PI / 180 );
10974constexpr Angle rot = Angle(M_TWOPI);
0 commit comments