mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
refactor: quantity::number_
member renamed to quantity::value_
This commit is contained in:
@@ -90,7 +90,7 @@ using common_quantity_for = quantity<common_reference(Q1::reference, Q2::referen
|
|||||||
template<Reference auto R, RepresentationOf<get_quantity_spec(R).character> Rep = double>
|
template<Reference auto R, RepresentationOf<get_quantity_spec(R).character> Rep = double>
|
||||||
class quantity {
|
class quantity {
|
||||||
public:
|
public:
|
||||||
Rep number_; // needs to be public for a structural type
|
Rep value_; // needs to be public for a structural type
|
||||||
|
|
||||||
// member types and values
|
// member types and values
|
||||||
static constexpr Reference auto reference = R;
|
static constexpr Reference auto reference = R;
|
||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
|
|
||||||
template<detail::QuantityConvertibleTo<quantity> Q>
|
template<detail::QuantityConvertibleTo<quantity> Q>
|
||||||
constexpr explicit(!std::convertible_to<typename Q::rep, Rep>) quantity(const Q& q) :
|
constexpr explicit(!std::convertible_to<typename Q::rep, Rep>) quantity(const Q& q) :
|
||||||
number_(detail::sudo_cast<quantity>(q).value())
|
value_(detail::sudo_cast<quantity>(q).value())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,13 +154,13 @@ public:
|
|||||||
template<typename Self>
|
template<typename Self>
|
||||||
[[nodiscard]] constexpr auto&& value(this Self&& self) noexcept
|
[[nodiscard]] constexpr auto&& value(this Self&& self) noexcept
|
||||||
{
|
{
|
||||||
return std::forward<Self>(self).number_;
|
return std::forward<Self>(self).value_;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
[[nodiscard]] constexpr rep& value() & noexcept { return number_; }
|
[[nodiscard]] constexpr rep& value() & noexcept { return value_; }
|
||||||
[[nodiscard]] constexpr const rep& value() const& noexcept { return number_; }
|
[[nodiscard]] constexpr const rep& value() const& noexcept { return value_; }
|
||||||
[[nodiscard]] constexpr rep&& value() && noexcept { return std::move(number_); }
|
[[nodiscard]] constexpr rep&& value() && noexcept { return std::move(value_); }
|
||||||
[[nodiscard]] constexpr const rep&& value() const&& noexcept { return std::move(number_); }
|
[[nodiscard]] constexpr const rep&& value() const&& noexcept { return std::move(value_); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
} -> std::same_as<rep&>;
|
} -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
++number_;
|
++value_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ public:
|
|||||||
} -> std::common_with<rep>;
|
} -> std::common_with<rep>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
return make_quantity<reference>(number_++);
|
return make_quantity<reference>(value_++);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr quantity& operator--()
|
constexpr quantity& operator--()
|
||||||
@@ -226,7 +226,7 @@ public:
|
|||||||
} -> std::same_as<rep&>;
|
} -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
--number_;
|
--value_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ public:
|
|||||||
} -> std::common_with<rep>;
|
} -> std::common_with<rep>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
return make_quantity<reference>(number_--);
|
return make_quantity<reference>(value_--);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr quantity& operator+=(const quantity& q)
|
constexpr quantity& operator+=(const quantity& q)
|
||||||
@@ -247,7 +247,7 @@ public:
|
|||||||
} -> std::same_as<rep&>;
|
} -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
number_ += q.value();
|
value_ += q.value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ public:
|
|||||||
} -> std::same_as<rep&>;
|
} -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
number_ -= q.value();
|
value_ -= q.value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr quantity& operator*=(const Value& v)
|
constexpr quantity& operator*=(const Value& v)
|
||||||
{
|
{
|
||||||
number_ *= v;
|
value_ *= v;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr quantity& operator*=(const Q& rhs)
|
constexpr quantity& operator*=(const Q& rhs)
|
||||||
{
|
{
|
||||||
number_ *= rhs.value();
|
value_ *= rhs.value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ public:
|
|||||||
constexpr quantity& operator/=(const Value& v)
|
constexpr quantity& operator/=(const Value& v)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||||
number_ /= v;
|
value_ /= v;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ public:
|
|||||||
constexpr quantity& operator/=(const Q& rhs)
|
constexpr quantity& operator/=(const Q& rhs)
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(rhs.value() != quantity_values<typename Q::rep>::zero());
|
gsl_ExpectsAudit(rhs.value() != quantity_values<typename Q::rep>::zero());
|
||||||
number_ /= rhs.value();
|
value_ /= rhs.value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ public:
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
gsl_ExpectsAudit(q.value() != quantity_values<rep>::zero());
|
gsl_ExpectsAudit(q.value() != quantity_values<rep>::zero());
|
||||||
number_ %= q.value();
|
value_ %= q.value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ private:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires detail::RepSafeConstructibleFrom<rep, Value&&, unit>
|
requires detail::RepSafeConstructibleFrom<rep, Value&&, unit>
|
||||||
constexpr explicit quantity(Value&& v) : number_(std::forward<Value>(v))
|
constexpr explicit quantity(Value&& v) : value_(std::forward<Value>(v))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user