
Andy Little wrote:
Can the dimension checking part of the library be used without the SI unit system? For most other unit systems I use, I mainly need dimension checking and not conversions between different units, such as km or m? Thus just a quantity with dimensions would be useful to catch programming errors.
Yes. In the signature fixed_quantity<Unit, ValueType>, the Unit parameter can be so modelled that it only allows base units to be used, and in this case there is no conversion overhead BTW, a multiply is simply a multiply of the numeric values for example). By default Quan wont work across Unit models (IOW the class template names of units must match), which means that attempting to do calculations between Units with different class template names will fail at compile time. By this means you can guarantee that you can prevent any conversions. (FWIW there is also the option to allow unit conversions but make them explicit, prompted by Deane Yang easrlier in this thread.)
I guess I wasn't particularly clear earlier in this thread, because fixed_quantity appears to be what I want. I'm sorry for not RTFM (I did try to read the documentation once, but my memory is not what it used to be), but I have two quick questions: 1) Does operator*(fixed_quantity<Unit1, ValueType1> x, fixed_quantity<Unit2, ValueType2> y) work and, if so, what is the result type, assuming that operator*(ValueType1 v, ValueType2 w) returns a ValueType3? 2) Can you raise a fixed_quantity to a rational power (I personally only need the power 1/2)? Deane