4 ms·
In C++, there are a few very nice libraries for computation with units, e.g.: https://github.com/mpusz/mp-units https://github.com/mpusz/mp-units which does a
by einpoklum 2y ago
In C++, there are a few very nice libraries for computation with units, e.g.:
https://github.com/mpusz/mp-units https://github.com/mpusz/mp-units
which does all sorts of checking, allows arithmetic with proper accounting for units and so on. But yes, the basic notion is wrapping things in structs which can't be simply assigned to each other.