temperature.in<si::Celsius>() auto
operator"" _rpmPerVolt (long double x) {
return decltype (1_rpm / 1_V)(x);
}
I have a macro for that: #define SI_DEFINE_LITERAL(xUnit, xliteral) \
[[nodiscard]] \
constexpr Quantity<units::xUnit> \
operator"" xliteral (long double value) \
{ \
return Quantity<units::xUnit> (value); \
} \
\
[[nodiscard]] \
constexpr Quantity<units::xUnit> \
operator"" xliteral (unsigned long long value) \
{ \
return Quantity<units::xUnit> (value); \
}
// Base SI units:
SI_DEFINE_LITERAL (Meter, _m)
SI_DEFINE_LITERAL (Kilogram, _kg)
SI_DEFINE_LITERAL (Second, _s)
SI_DEFINE_LITERAL (Ampere, _A)
SI_DEFINE_LITERAL (Kelvin, _K)
SI_DEFINE_LITERAL (Mole, _mol)
SI_DEFINE_LITERAL (Candela, _cd)
SI_DEFINE_LITERAL (Radian, _rad)
...and a loong list of other common units here. using Foot = ScaledUnit<Meter, std::ratio<1'200, 3'937>>;
using Mile = ScaledUnit<Meter, std::ratio<1'609'344, 1'000>>;
using NauticalMile = ScaledUnit<Meter, std::ratio<1'852, 1>>;
using Inch = ScaledUnit<Meter, std::ratio<254, 10'000>>;
And then I use SI_DEFINE_LITERAL (NauticalMile, _nm); etc. si::Length length = 15_m + 12_nm; // _nm for Nautical Miles
si::Area area = 1_m * 1_km; // Equals to 1000_m2
si::Power power = 1_m / 1_sec / 1_sec; // Compilation error, 1_m/s² is not a si::Power
I don't have every possible User-Defined Literal, of course, so I end up doing this for less common units: using SomeLocalTypeName = decltype(1_rpm / 1_V);
Something to thing about, when designing such library:
Maybe it all boils down to how CPUs work, and maybe it's safe to say that the incompleteness comes from the CPU implementation? You can of course argue that Python interpreters are written in C/C++, but of course we can imagine they can be written in assembly.
Edit: after I read some other comments I think I see the point - that indeed the problem is the implementation (on CPU).