Cpp Utilities 1.2.3
|
Helper classes, typedefs and functions for dimensional analyse. More...
Namespaces | |
namespace | Dimensional |
Namespace for all classes, typedefs and functions of dimensional analyse. See Dimensional Analysis for more instrucion. | |
Helper classes, typedefs and functions for dimensional analyse.
Provide helperful functionalities for dimensional analysis with pros:
Zero-cost abstraction Using template to encapsulate functionalities, grants same memory-layout and runtime performance as primitive types.
Strong typed All values in dimensional objects has its unique unit**, calculation between them is guaranteed by compiler warning and error.
Non-standard unit of same "type", like yard
vs meter
, is supported, and will be regarded like same unit, std::ratio
is used for modifier of the unit. Calculations between same unit with different ratio is safe, ratios of each operand will be performed into the calculation.
Add/subtract with same unit is allowed, whereas with different units will cause compile error.
Multiply/divide values with any units is safe, a new value with new unit will be generated.
User defined unit is supported. Helper types is provided to derive new unit from existsing units.
Sample Code