![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
A class representing a quantity of a physical units type. More...

Public Member Functions | |
| constexpr | quantity () noexcept |
| Default construct with a default-constructed representation value. | |
| template<typename OtherQuantityType, typename OtherRep, constraints< std::enable_if_t< quantity_detail::is_implicitly_convertible_v< OtherQuantityType, QuantityType > >, std::enable_if_t< quantity_detail::scaled_value_in_range_v< OtherQuantityType, OtherRep, QuantityType, Rep > > > = nullptr> | |
| constexpr | quantity (quantity< OtherQuantityType, OtherRep > const &other) noexcept |
| Implicitly convert from a quantity with a different physical units type or representation type, scaling the value as appropriate. | |
| constexpr | quantity (Rep store_value) noexcept |
Construct a quantity holding the specified representation value. | |
| template<typename OtherQuantityType, typename OtherRep = Rep, constraints< std::enable_if_t< quantity_detail::is_explicitly_convertible_v< QuantityType, OtherQuantityType > > > = nullptr> | |
| constexpr auto | as () const noexcept -> quantity< OtherQuantityType, OtherRep > |
| Convert the stored quantity to the specified physical units type and representation. | |
| template<typename OtherQuantityType, typename OtherRep = Rep, constraints< std::enable_if_t< quantity_detail::is_explicitly_convertible_v< QuantityType, OtherQuantityType > > > = nullptr> | |
| constexpr auto | count_of () const noexcept -> OtherRep |
| Get the numeric representation of the stored quantity, for the specified physical units type. | |
Static Public Member Functions | |
| static constexpr auto | three_way_compare (quantity const &lhs, quantity const &rhs) noexcept -> strong_ordering |
| three-way comparison between two quantities | |
| template<typename OtherRep> | |
| static constexpr auto | three_way_compare (quantity const &lhs, quantity< QuantityType, OtherRep > const &rhs) noexcept -> strong_ordering |
| three-way comparison between two quantities with the same physical units but different representations | |
| template<typename OtherQuantityType, typename OtherRep, constraints< std::enable_if_t< quantity_detail::is_implicitly_convertible_v< OtherQuantityType, QuantityType > >, std::enable_if_t< quantity_detail::scaled_value_in_range_v< OtherQuantityType, OtherRep, QuantityType, std::common_type_t< Rep, OtherRep > > > > = nullptr> | |
| static constexpr auto | three_way_compare (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> strong_ordering |
| three-way comparison between two quantities with different physical units | |
| template<typename OtherQuantityType, typename OtherRep, constraints< std::enable_if_t< quantity_detail::is_implicitly_convertible_v< OtherQuantityType, QuantityType > >, std::enable_if_t<!quantity_detail::scaled_value_in_range_v< OtherQuantityType, OtherRep, QuantityType, std::common_type_t< Rep, OtherRep > > > > = nullptr> | |
| static constexpr auto | three_way_compare (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> strong_ordering |
| three-way comparison between two quantities with different physical units where one quantity type is not within the scaled range of the other | |
Friends | |
| template<typename Q = QuantityType, constraints< typename units_combination_traits< Q, Q >::sum_type > = nullptr> | |
| constexpr auto | operator+ (quantity const &lhs, quantity const &rhs) noexcept -> quantity< typename units_combination_traits< Q, Q >::sum_type, Rep > |
| Add two quantities of the same type. | |
| template<typename OtherQuantityType, typename OtherRep, typename Q = QuantityType, typename R = Rep, typename CommonRep = std::common_type_t<Rep, OtherRep>, constraints< typename units_combination_traits< QuantityType, OtherQuantityType >::ratio_type > = nullptr> | |
| constexpr auto | operator/ (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> quantity< typename units_combination_traits< QuantityType, OtherQuantityType >::ratio_type, CommonRep > |
| Divide two quantities. | |
| template<typename Scalar, typename Q = QuantityType, typename R = Rep, constraints< std::enable_if_t<!quantity_detail::is_quantity_v< Scalar > > > = nullptr, typename CommonRep = std::common_type_t<Rep, Scalar>, constraints< std::enable_if_t<!std::is_integral< CommonRep >::value > > = nullptr> | |
| constexpr auto | operator/ (quantity const &lhs, Scalar const &rhs) noexcept -> quantity< Q, CommonRep > |
| Divide a quantity by a scalar. | |
| template<typename OtherQuantityType, typename OtherRep, typename Q = QuantityType, typename R = Rep, typename CommonRep = std::common_type_t<Rep, OtherRep>, constraints< typename units_combination_traits< QuantityType, OtherQuantityType >::sum_type > = nullptr> | |
| constexpr auto | operator+ (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> quantity< typename units_combination_traits< QuantityType, OtherQuantityType >::sum_type, CommonRep > |
| Add two quantities. | |
| template<typename OtherQuantityType, typename OtherRep, typename Q = QuantityType, typename R = Rep, typename CommonRep = std::common_type_t<Rep, OtherRep>, constraints< typename units_combination_traits< QuantityType, OtherQuantityType >::difference_type > = nullptr> | |
| constexpr auto | operator- (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> quantity< typename units_combination_traits< QuantityType, OtherQuantityType >::difference_type, CommonRep > |
| Subtract two quantities. | |
| template<typename Scalar, typename Q = QuantityType, typename R = Rep, constraints< std::enable_if_t<!quantity_detail::is_quantity_v< Scalar > > > = nullptr, typename CommonRep = std::common_type_t<Rep, Scalar>> | |
| constexpr auto | operator* (quantity const &lhs, Scalar const &rhs) noexcept -> quantity< Q, CommonRep > |
| Multiply a quantity by a scalar. | |
| template<typename Scalar, typename Q = QuantityType, typename R = Rep, constraints< std::enable_if_t<!quantity_detail::is_quantity_v< Scalar > > > = nullptr, typename CommonRep = std::common_type_t<Rep, Scalar>> | |
| constexpr auto | operator* (Scalar const &lhs, quantity const &rhs) noexcept -> quantity< Q, CommonRep > |
| Multiply a quantity by a scalar. | |
| template<typename OtherQuantityType, typename OtherRep, typename Q = QuantityType, typename R = Rep, typename CommonRep = std::common_type_t<Rep, OtherRep>, constraints< typename units_combination_traits< QuantityType, OtherQuantityType >::product_type, std::enable_if_t<!std::is_integral< CommonRep >::value > > = nullptr> | |
| constexpr auto | operator* (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> quantity< typename units_combination_traits< QuantityType, OtherQuantityType >::product_type, CommonRep > |
| Multiply two quantities. | |
| template<typename OtherQuantityType, typename OtherRep, typename Q = QuantityType, typename R = Rep, typename CommonRep = std::common_type_t<Rep, OtherRep>, constraints< typename units_combination_traits< QuantityType, OtherQuantityType >::product_type, std::enable_if_t< std::is_integral< CommonRep >::value >, std::enable_if_t< std::is_signed< CommonRep >::value||(std::is_unsigned< R >::value &&std::is_unsigned< OtherRep >::value)>> | |
| constexpr auto | operator* (quantity const &lhs, quantity< OtherQuantityType, OtherRep > const &rhs) noexcept -> quantity< typename units_combination_traits< QuantityType, OtherQuantityType >::product_type, CommonRep > |
| Multiply two quantities. | |
Friends inherited from arene::base::generic_ordering_from_three_way_compare< quantity< QuantityType, Rep > > | |
A class representing a quantity of a physical units type.
Conversions and arithmetic are supported if indicated by the appropriate traits for the physical units tag type. This allows the mathematical operations of engineering equations to be performed using instances of quantity, ensuring that the units of the result are correct, and preventing errors due to passing incorrect values or values in the wrong units.
| QuantityType | A tag type representing the physical quantity |
| Rep | The arithmetic type to use for holding the value |
|
inlineconstexprnoexcept |
Default construct with a default-constructed representation value.
|
inlineexplicitconstexprnoexcept |
Construct a quantity holding the specified representation value.
| store_value | The value to store |
|
inlineconstexprnoexcept |
Implicitly convert from a quantity with a different physical units type or representation type, scaling the value as appropriate.
| OtherQuantityType | The physical units type of the source quantity |
| OtherRep | The representation type of the source quantity |
| other | The other quantity |
|
inlineconstexprnoexcept |
Convert the stored quantity to the specified physical units type and representation.
The value is scaled as appropriate
| OtherQuantityType | The physical units type for which to retrieve the count |
| OtherRep | The representation type to return the count in; defaults to Rep |
QuantityType must be marked as explicitly convertible to OtherQuantityType
|
inlineconstexprnoexcept |
Get the numeric representation of the stored quantity, for the specified physical units type.
The value is scaled as appropriate
| OtherQuantityType | The physical units type for which to retrieve the count |
| OtherRep | The representation type to return the count in; defaults to Rep |
QuantityType must be marked as explicitly convertible to OtherQuantityType
|
inlinestaticconstexprnoexcept |
three-way comparison between two quantities
| lhs | The first object to compare |
| rhs | The second object to compare |
strong_ordering::less if lhs is less than rhs, strong_ordering::equal if they hold the same value, and strong_ordering::greater if lhs is greater than rhs
|
inlinestaticconstexprnoexcept |
three-way comparison between two quantities with different physical units
| lhs | The first object to compare |
| rhs | The second object to compare |
strong_ordering::less if lhs is less than rhs, strong_ordering::equal if they hold the same value, and strong_ordering::greater if lhs is greater than rhs
|
inlinestaticconstexprnoexcept |
three-way comparison between two quantities with different physical units where one quantity type is not within the scaled range of the other
| lhs | The first object to compare |
| rhs | The second object to compare |
strong_ordering::less if lhs is less than rhs, strong_ordering::equal if they hold the same value, and strong_ordering::greater if lhs is greater than rhs
|
inlinestaticconstexprnoexcept |
three-way comparison between two quantities with the same physical units but different representations
| lhs | The first object to compare |
| rhs | The second object to compare |
strong_ordering::less if lhs is less than rhs, strong_ordering::equal if they hold the same value, and strong_ordering::greater if lhs is greater than rhs
|
friend |
Multiply two quantities.
| OtherQuantityType | The physical units type of the other quantity |
| OtherRep | The representation type of the other quantity |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and OtherRep |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the physical units type specified as the product_type for QuantityType and OtherQuantityType, and a representation which is the common type of Rep and OtherRep, holding the product of the two quantity values product_type specified in units_combination_traits<QuantityType,OtherQuantityType>
|
friend |
Multiply two quantities.
| OtherQuantityType | The physical units type of the other quantity |
| OtherRep | The representation type of the other quantity |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and OtherRep |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the physical units type specified as the product_type for QuantityType and OtherQuantityType, and a representation which is the common type of Rep and OtherRep, holding the left hand quantity value multiplied by the right hand quantity value product_type specified in units_combination_traits<QuantityType,OtherQuantityType>
|
friend |
Multiply a quantity by a scalar.
| Scalar | The type of the scalar |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and Scalar |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the same physical units type, and a representation which is the common type of Rep and Scalar, holding the product of the quantity value and the scalar value
|
friend |
Multiply a quantity by a scalar.
| Scalar | The type of the scalar |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and Scalar |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the same physical units type, and a representation which is the common type of Rep and Scalar, holding the quantity value multiplied by the scalar value
|
friend |
Add two quantities of the same type.
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| lhs | The first quantity |
| rhs | The second quantity |
quantity with the physical units type specified as the sum_type for QuantityType and QuantityType, and a representation of Rep, holding the sum of the two quantity values
|
friend |
Add two quantities.
| OtherQuantityType | The physical units type of the other quantity |
| OtherRep | The representation type of the other quantity |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| lhs | The first quantity |
| rhs | The second quantity |
quantity with the physical units type specified as the sum_type for QuantityType and OtherQuantityType, and a representation which is the common type of Rep and OtherRep, holding the sum of the two quantity values
|
friend |
Subtract two quantities.
| OtherQuantityType | The physical units type of the other quantity |
| OtherRep | The representation type of the other quantity |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| lhs | The first quantity |
| rhs | The second quantity |
quantity with the physical units type specified as the difference_type for QuantityType and OtherQuantityType, and a representation which is the common type of Rep and OtherRep, holding the difference of the two quantity values
|
friend |
Divide two quantities.
| OtherQuantityType | The physical units type of the other quantity |
| OtherRep | The representation type of the other quantity |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and OtherRep |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the physical units type specified as the ratio_type for QuantityType and OtherQuantityType, and a representation which is the common type of Rep and OtherRep, holding the left hand quantity value divided by the right hand quantity value ratio_type specified in units_combination_traits<QuantityType,OtherQuantityType>
|
friend |
Divide a quantity by a scalar.
| Scalar | The type of the scalar |
| Q | Template parameter introduced to provide constraints; equivalent to QuantityType |
| R | Template parameter introduced to provide constraints; equivalent to Rep |
| CommonRep | Template parameter introduced to provide constraints; the common representation type of Rep and Scalar |
| lhs | The left hand operand |
| rhs | The right hand operand |
quantity with the same physical units type, and a representation which is the common type of Rep and Scalar, holding the quantity value divided by the scalar value