Quantity¶
-
template<IsDimensionality Dim, IsRatioOrTag Scale>
class Quantity¶ Primary template for representing physical quantities with dimensions and scale.
This class template provides type-safe representation of physical quantities with automatic unit conversion, dimensional analysis, and arithmetic operations. It stores values internally and provides conversion to SI units through the scale parameter.
- Template Parameters:
Dim – The dimensionality of the quantity (e.g., Length, Time, Mass)
Scale – The scale/ratio for unit conversion (e.g., std::kilo, std::milli) or a unit tag
Public Functions
-
template<IsRatioOrTag OtherScale>
inline constexpr Quantity(const Quantity<Dim, OtherScale> &other)¶
-
inline constexpr Quantity()¶
-
inline constexpr operator double() const¶
-
double to_si() const¶
Get the value in SI units.
Converts the internal value to the SI base unit for this dimension by applying the appropriate scale conversion.
- Template Parameters:
Dim – The dimensionality of the quantity
Scale – The scale type of the quantity
- Returns:
double The value converted to SI units
-
double value() const¶
Get the raw value in the current scale.
Returns the stored value without any unit conversion.
- Template Parameters:
Dim – The dimensionality of the quantity
Scale – The scale type of the quantity
- Returns:
double The value in the current unit scale
-
double raw_value() const¶
Get the raw value (alias for value())
Returns the stored value without any unit conversion. This is an alias for value() provided for compatibility.
- Template Parameters:
Dim – The dimensionality of the quantity
Scale – The scale type of the quantity
- Returns:
double The value in the current unit scale
-
template<IsRatioOrTag NewScale>
inline Quantity<Dim, NewScale> as() const¶
-
template<typename QuantityType>
inline auto as() const¶
-
std::string to_string() const¶
Convert quantity to string representation.
Formats the quantity as a string with the SI value followed by the SI unit string for this dimension.
- Template Parameters:
Dim – The dimensionality of the quantity
Scale – The scale type of the quantity
- Returns:
std::string String representation showing value and SI unit
-
double to_si(double value) const¶
-
double to_si(double value) const