.. namespace:: units quantity ======== Interface --------- `quantity` class template provides a similar interface to `std::chrono::duration `_. The difference is that it uses ``double`` as a default representation and has a few additional member types and functions:: template U, Scalar Rep = double> class quantity { public: using dimension = D; using unit = U; using rep = Rep; [[nodiscard]] static constexpr quantity one() noexcept; // ... }; template requires detail::basic_arithmetic && equivalent_dim> [[nodiscard]] constexpr Scalar auto operator*(const quantity& lhs, const quantity& rhs); template requires detail::basic_arithmetic && (!equivalent_dim>) [[nodiscard]] constexpr Quantity auto operator*(const quantity& lhs, const quantity& rhs); template requires std::magma [[nodiscard]] constexpr Quantity auto operator/(const Value& v, const quantity& q); template requires detail::basic_arithmetic && equivalent_dim [[nodiscard]] constexpr Scalar auto operator/(const quantity& lhs, const quantity& rhs); template requires detail::basic_arithmetic && (!equivalent_dim) [[nodiscard]] constexpr Quantity AUTO operator/(const quantity& lhs, const quantity& rhs); Additional functions provide the support for operations that result in a different dimension type than those of their arguments. ``equivalent_dim`` constraint requires two dimensions to be either the same or have convertible units of base dimension (with the same reference unit). Beside adding new elements a few other changes where applied compared to the `std::chrono::duration `_ class template: 1. The ``duration`` is using ``std::common_type_t`` to find a common representation for a calculation result. Such a design was reported as problematic by SG6 (numerics study group) members as sometimes we want to provide a different type in case of multiplication and different in case of division. ``std::common_type`` lacks that additional information. That is why `units::quantity` uses the resulting type of a concrete operator operation. 2. `operator %` is constrained with `treat_as_floating_point` type trait to limit the types to integral representations only. Also `operator %(Rep)` takes `Rep` as a template argument to limit implicit conversions.