@@ -130,7 +130,7 @@ void quantityChecker(Quantity<Mass, Length, Time, Current, Angle, Temperature, L
130130template <typename Q>
131131concept isQuantity = requires (Q q) { quantityChecker (q); };
132132
133- // Isomorphic concept - used to ensure unit equivalecy
133+ // Isomorphic concept - used to ensure unit equivalency
134134template <typename Q, typename ... Quantities>
135135concept Isomorphic = ((std::convertible_to<Q, Quantities> && std::convertible_to<Quantities, Q>) && ...);
136136
@@ -357,6 +357,57 @@ constexpr inline Number from_num(double value) { return Number(value); }
357357
358358constexpr inline double to_num (Number quantity) { return quantity.internal (); }
359359
360+ #define NEW_NUM_TO_DOUBLE_COMPARISON (op ) \
361+ constexpr bool operator op (Number lhs, double rhs) { return (lhs.internal () op rhs); } \
362+ constexpr bool operator op (double lhs, Number rhs) { return (lhs op rhs.internal ()); }
363+
364+ NEW_NUM_TO_DOUBLE_COMPARISON (==)
365+ NEW_NUM_TO_DOUBLE_COMPARISON(!=)
366+ NEW_NUM_TO_DOUBLE_COMPARISON(<=)
367+ NEW_NUM_TO_DOUBLE_COMPARISON(>=)
368+ NEW_NUM_TO_DOUBLE_COMPARISON(<)
369+ NEW_NUM_TO_DOUBLE_COMPARISON(>)
370+
371+ #define NEW_NUM_AND_DOUBLE_OPERATION (op ) \
372+ constexpr Number operator op (Number lhs, double rhs) { return (lhs.internal () op rhs); } \
373+ constexpr Number operator op (double lhs, Number rhs) { return (lhs op rhs.internal ()); }
374+
375+ NEW_NUM_AND_DOUBLE_OPERATION (+)
376+ NEW_NUM_AND_DOUBLE_OPERATION(-)
377+ NEW_NUM_AND_DOUBLE_OPERATION(*)
378+ NEW_NUM_AND_DOUBLE_OPERATION(/)
379+
380+ #define NEW_NUM_AND_DOUBLE_ASSIGNMENT (op ) \
381+ constexpr void operator op##=(Number& lhs, double rhs) { lhs = lhs.internal () op rhs; } \
382+ constexpr void operator op##=(double & lhs, Number rhs) { lhs = lhs op rhs.internal (); }
383+
384+ NEW_NUM_AND_DOUBLE_ASSIGNMENT (+)
385+ NEW_NUM_AND_DOUBLE_ASSIGNMENT(-)
386+ NEW_NUM_AND_DOUBLE_ASSIGNMENT(*)
387+ NEW_NUM_AND_DOUBLE_ASSIGNMENT(/)
388+
389+ constexpr Number& operator++(Number& lhs, int ) {
390+ lhs += 1 ;
391+ return lhs;
392+ }
393+
394+ constexpr Number operator ++(Number& lhs) {
395+ Number copy = lhs;
396+ lhs += 1 ;
397+ return copy;
398+ }
399+
400+ constexpr Number& operator --(Number& lhs, int ) {
401+ lhs -= 1 ;
402+ return lhs;
403+ }
404+
405+ constexpr Number operator --(Number& lhs) {
406+ Number copy = lhs;
407+ lhs -= 1 ;
408+ return copy;
409+ }
410+
360411NEW_UNIT_LITERAL (Number, percent, num / 100 )
361412
362413NEW_UNIT(Mass, kg, 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
0 commit comments