|
using | value_type = float |
|
constexpr | quantity () noexcept |
|
constexpr | quantity (Value val) noexcept |
| Default constructor used to create a physical quantity from value. More...
|
|
constexpr float | operator* () const noexcept |
| Const reference to the internal value. More...
|
|
constexpr physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > & | operator+= (quantity const other) noexcept |
| Add other quantity of same Derived and value_type. More...
|
|
constexpr physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > & | operator-= (quantity const other) noexcept |
| Subtract other quantity of same Derived and value_type. More...
|
|
constexpr physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > & | operator/= (arithmetic auto const val) noexcept |
| Divides quantity by it's value type. More...
|
|
constexpr physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte > & | operator*= (arithmetic auto const val) noexcept |
| Multiplies quantity by it's value type. More...
|
|
constexpr | operator U () const noexcept |
| Provides explicit conversion of internal value to type U. More...
|
|
template<int Len, int Mass, int Time, int Current, int Temp, int Mol, int Li, int Angle, int Byte>
struct emlabcpp::physical_quantity< Len, Mass, Time, Current, Temp, Mol, Li, Angle, Byte >
physical_quantity represents all physical units defined using the International System of Units and more.
The idea is that each used unit, is either one of the seven basic units, or defined as some combination of them. The combination is multiplication of exponents of basic units.
So, velocity is distance per time - m*s^-1.
We defined each physical unit by using a template, that has exponent of each basic unit as exponent. This makes it possible to specify any unit using this class - as combination of basic units.
We expand this by providing two additional 'basic' units - angle (which is handy for us) and byte.
Given that we have the exponents of basic units as integers in the type, we can write generic multiplication and division between all possible templates.
This trick is inspired by the haskell's dimensional library which does the same.