Unit-Safe Physical Quantities
Encode physical units in the type system so adding volts to amperes is a compile error, and dividing volts by amperes yields ohms.
Constraints
- Template on integer exponents for voltage, current and time.
- Addition and subtraction only between identical unit types.
- Multiplication and division must add and subtract exponents.
- All arithmetic constexpr.
- No runtime overhead over a bare double.
- Provide literal helpers for volts and amperes.
1template <int V, int A, int S>2struct Quantity {3 double value;4 // TODO5};