@@ -261,7 +261,7 @@ template <isQuantity Q, isQuantity R> constexpr bool operator>(const Q& lhs, con
261
261
return (lhs.internal () > rhs.internal ());
262
262
}
263
263
264
- #define NEW_UNIT (Name, suffix, m, l, t, i, a, o, j, n ) \
264
+ #define NEW_UNIT_FULL (Name, suffix, m, l, t, i, a, o, j, n, extra ) \
265
265
class Name : public Quantity <std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, \
266
266
std::ratio<o>, std::ratio<j>, std::ratio<n>> { \
267
267
public: \
@@ -273,6 +273,7 @@ template <isQuantity Q, isQuantity R> constexpr bool operator>(const Q& lhs, con
273
273
value) \
274
274
: Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, std::ratio<o>, \
275
275
std::ratio<j>, std::ratio<n>>(value) {}; \
276
+ extra \
276
277
}; \
277
278
template <> struct LookupName <Quantity<std::ratio<m>, std::ratio<l>, std::ratio<t>, std::ratio<i>, std::ratio<a>, \
278
279
std::ratio<o>, std::ratio<j>, std::ratio<n>>> { \
@@ -294,6 +295,8 @@ template <isQuantity Q, isQuantity R> constexpr bool operator>(const Q& lhs, con
294
295
constexpr inline Name from_##suffix(double value) { return Name (value); } \
295
296
constexpr inline double to_##suffix(Name quantity) { return quantity.internal (); }
296
297
298
+ #define NEW_UNIT (Name, suffix, m, l, t, i, a, o, j, n ) NEW_UNIT_FULL(Name, suffix, m, l, t, i, a, o, j, n, )
299
+
297
300
#define NEW_UNIT_LITERAL (Name, suffix, multiple ) \
298
301
[[maybe_unused]] constexpr Name suffix = multiple; \
299
302
constexpr Name operator " " _##suffix(long double value) { return static_cast <double >(value) * multiple; } \
@@ -312,7 +315,7 @@ template <isQuantity Q, isQuantity R> constexpr bool operator>(const Q& lhs, con
312
315
NEW_UNIT_LITERAL(Name, u##base, base / 1E6 ) \
313
316
NEW_UNIT_LITERAL(Name, n##base, base / 1E9 )
314
317
315
- NEW_UNIT (Number, num, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
318
+ NEW_UNIT_FULL (Number, num, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , constexpr operator double () { return this -> value ; } )
316
319
NEW_UNIT_LITERAL(Number, percent, num / 100.0 );
317
320
318
321
NEW_UNIT (Mass, kg, 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
0 commit comments