|
Unit Conversion and Dimensional Analysis Library 3.6.1
A compile-time, header-only C++23 dimensional-analysis library
|
Functions used to convert values of one logical type to another. More...
Functions | |
| template<ConversionFactorType ConversionFactorFrom, ConversionFactorType ConversionFactorTo, ArithmeticType To = double, ArithmeticType From> requires (traits::is_same_dimension_conversion_factor_v<ConversionFactorFrom, ConversionFactorTo>) | |
| constexpr To | units::convert (const From &value) noexcept |
| converts a value from an unit to another. | |
| template<UnitType UnitTo, UnitType UnitFrom> requires same_dimension<UnitFrom, UnitTo> | |
| constexpr UnitTo | units::convert (const UnitFrom &from) noexcept |
| converts an unit to another unit. | |
| template<ArithmeticType T, UnitType Unit> | |
| constexpr T | units::unit_cast (const Unit &value) noexcept |
| Casts an unit to an arithmetic type. | |
Functions used to convert values of one logical type to another.
|
constexprnoexcept |
converts a value from an unit to another.
Converts a value of an arithmetic type to another unit. E.g.
Intermediate computations are carried in the widest representation before being converted to To. is_same_dimension_conversion_factor_v<ConversionFactorFrom, ConversionFactorTo> shall be true.
| ConversionFactorFrom | conversion factor of the unit to convert value from. is_conversion_factor_v<ConversionFactorFrom> shall be true. |
| ConversionFactorTo | conversion factor of the unit to convert value to. is_conversion_factor_v<ConversionFactorTo> shall be true. |
| From | type of value. Shall be an arithmetic type. |
| [in] | value | Arithmetic value to convert. The value should represent a quantity in units of ConversionFactorFrom. |
| To | type of the converted unit value. Shall be an arithmetic type. |
|
constexprnoexcept |
converts an unit to another unit.
Converts the value of an unit to another unit. E.g.
Intermediate computations are carried in the widest representation before being converted to UnitTo. is_same_dimension_unit_v<UnitFrom, UnitTo> shall be true.
| UnitFrom | unit to convert to UnitTo. is_unit_v<UnitFrom> shall be true. |
| UnitTo | unit to convert from to. is_unit_v<UnitTo> shall be true. |
|
constexprnoexcept |
Casts an unit to an arithmetic type.
unit_cast can be used to remove the strong typing from an unit class, and convert it to an arithmetic type. This may be useful for compatibility with libraries and legacy code that don't support unit types. E.g
| T | Type to cast the unit type to. Shall be an arithmetic type. |
| Unit | Type of the unit to cast to. |
| value | Unit value to cast. |