Hacker News new | ask | show | jobs
by antoineMoPa 948 days ago
Can you provide examples?
4 comments

https://crates.io/crates/uom trivially convertable to cpp
- you define a template class accepting 1 constant integer for each dimension you want to consider (length and/or time and/or mass and/or temperature);

- you define addition and subtraction between objects of one type returning an object of the same type;

- you define multiplication and division as returning an object of a type with the dimensions summed or subtracted;

- and you get dimensional correctness via type safety.