4 ms·
For C++ you can use boost units. It is basically built up of template magic which only compiles when your units are correct. The disadvantage: when it doesn't,
by rubenbe 5y ago
For C++ you can use boost units. It is basically built up of template magic which only compiles when your units are correct.
The disadvantage: when it doesn't, it explodes in a huge template error. But when it does, you can be pretty certain (depending on the actual calculation) that your code is correct. It is also fully verified at compile time, so there is no runtime overhead.
https://www.boost.org/doc/libs/1_78_0/doc/html/boost_units.html https://www.boost.org/doc/libs/1_78_0/doc/html/boost_units.h...