safe-arithmetic
safe-arithmetic copied to clipboard
🧑🔬 Make sure safe arithmetic works with a dimensional analysis library (like mpusz/units)
Some notes on how this might work.
safe::var<int, ival<0, 1023>, km / h> current_speed = 100_s32 * km / h;
constexpr auto speed_limit = 100_s32 * km / h;
units::some_type<safe::var<int, ival<0, 1023>>> current_speed = 100_s32 * km / h;
safe::var<unit::some_type<int, km / h>, ival<0, 1023>> current_speed = 100_s32 * km / h;
units::some_type<safe::var<int, ival<100, 100>>>
another variation of the top that does a better job satisfying the DRY principle:
auto current_speed = s32_ival<0, 1023>{100_s32} * km / h;