style: quantity header cleanup

This commit is contained in:
Mateusz Pusz
2022-12-23 18:01:51 +01:00
parent c056f4535c
commit e2a2076c8d

View File

@@ -71,10 +71,9 @@ concept invoke_result_of_ =
* @brief A quantity * @brief A quantity
* *
* Property of a phenomenon, body, or substance, where the property has a magnitude that can be * Property of a phenomenon, body, or substance, where the property has a magnitude that can be
* expressed by means of a number and a measurement unit. * expressed by means of a number and a reference.
* *
* @tparam D a dimension of the quantity (can be either a BaseDimension or a DerivedDimension) * @tparam R a reference of the quantity providing all information about quantity properties
* @tparam U a measurement unit of the quantity
* @tparam Rep a type to be used to represent values of a quantity * @tparam Rep a type to be used to represent values of a quantity
*/ */
template<Reference auto R, RepresentationOf<R.quantity_spec.character> Rep = double> template<Reference auto R, RepresentationOf<R.quantity_spec.character> Rep = double>
@@ -82,11 +81,11 @@ class quantity {
Rep number_; Rep number_;
public: public:
// member types and values // member types and values
using rep = Rep;
static constexpr Reference auto reference = R; static constexpr Reference auto reference = R;
static constexpr QuantitySpec auto quantity_spec = R.quantity_spec; static constexpr QuantitySpec auto quantity_spec = reference.quantity_spec;
static constexpr Dimension auto dimension = R.dimension; static constexpr Dimension auto dimension = reference.dimension;
static constexpr Unit auto unit = R.unit; static constexpr Unit auto unit = reference.unit;
using rep = Rep;
// static member functions // static member functions
[[nodiscard]] static constexpr quantity zero() noexcept [[nodiscard]] static constexpr quantity zero() noexcept
@@ -253,6 +252,7 @@ public:
number_ *= rhs; number_ *= rhs;
return *this; return *this;
} }
template<detail::quantity_one Q> template<detail::quantity_one Q>
constexpr quantity& operator*=(const Q& rhs) constexpr quantity& operator*=(const Q& rhs)
requires requires(rep a, const typename Q::rep b) { requires requires(rep a, const typename Q::rep b) {
@@ -277,6 +277,7 @@ public:
number_ /= rhs; number_ /= rhs;
return *this; return *this;
} }
template<detail::quantity_one Q> template<detail::quantity_one Q>
constexpr quantity& operator/=(const Q& rhs) constexpr quantity& operator/=(const Q& rhs)
requires requires(rep a, const typename Q::rep b) { requires requires(rep a, const typename Q::rep b) {