mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
refactor: 💥 quantity_values
renamed to representation values
This commit is contained in:
@ -87,9 +87,9 @@ constexpr bool is_tensor = false;
|
||||
*/
|
||||
template<typename Rep>
|
||||
#if MP_UNITS_HOSTED
|
||||
struct quantity_values : std::chrono::duration_values<Rep> {
|
||||
struct representation_values : std::chrono::duration_values<Rep> {
|
||||
#else
|
||||
struct quantity_values {
|
||||
struct representation_values {
|
||||
static constexpr Rep zero() noexcept
|
||||
requires std::constructible_from<Rep, int>
|
||||
{
|
||||
@ -120,6 +120,9 @@ struct quantity_values {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Rep>
|
||||
using quantity_values [[deprecated("Use `representation_values` instead")]] = representation_values<Rep>;
|
||||
|
||||
/**
|
||||
* @brief Provides support for external quantity-like types
|
||||
*
|
||||
|
@ -143,27 +143,27 @@ public:
|
||||
|
||||
// static member functions
|
||||
[[nodiscard]] static constexpr quantity zero() noexcept
|
||||
requires requires { quantity_values<rep>::zero(); }
|
||||
requires requires { representation_values<rep>::zero(); }
|
||||
{
|
||||
return {quantity_values<rep>::zero(), R};
|
||||
return {representation_values<rep>::zero(), R};
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr quantity one() noexcept
|
||||
requires requires { quantity_values<rep>::one(); }
|
||||
requires requires { representation_values<rep>::one(); }
|
||||
{
|
||||
return {quantity_values<rep>::one(), R};
|
||||
return {representation_values<rep>::one(), R};
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr quantity min() noexcept
|
||||
requires requires { quantity_values<rep>::min(); }
|
||||
requires requires { representation_values<rep>::min(); }
|
||||
{
|
||||
return {quantity_values<rep>::min(), R};
|
||||
return {representation_values<rep>::min(), R};
|
||||
}
|
||||
|
||||
[[nodiscard]] static constexpr quantity max() noexcept
|
||||
requires requires { quantity_values<rep>::max(); }
|
||||
requires requires { representation_values<rep>::max(); }
|
||||
{
|
||||
return {quantity_values<rep>::max(), R};
|
||||
return {representation_values<rep>::max(), R};
|
||||
}
|
||||
|
||||
// construction, assignment, destruction
|
||||
@ -446,7 +446,7 @@ public:
|
||||
}
|
||||
friend constexpr decltype(auto) operator/=(Q&& lhs, const Value& val)
|
||||
{
|
||||
MP_UNITS_EXPECTS_DEBUG(val != quantity_values<Value>::zero());
|
||||
MP_UNITS_EXPECTS_DEBUG(val != representation_values<Value>::zero());
|
||||
// TODO use /= when compiler bug is resolved:
|
||||
// https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445
|
||||
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ / val;
|
||||
@ -577,7 +577,7 @@ public:
|
||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, Rep, const Value&>
|
||||
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator/(const Q& q, const Value& val)
|
||||
{
|
||||
MP_UNITS_EXPECTS_DEBUG(val != quantity_values<Value>::zero());
|
||||
MP_UNITS_EXPECTS_DEBUG(val != representation_values<Value>::zero());
|
||||
return ::mp_units::quantity{q.numerical_value_ref_in(unit) / val, R};
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace mp_units {
|
||||
*/
|
||||
template<std::intmax_t Num, std::intmax_t Den = 1, auto R, typename Rep>
|
||||
requires detail::non_zero<Den> && requires(Rep v) {
|
||||
quantity_values<Rep>::one();
|
||||
representation_values<Rep>::one();
|
||||
requires requires { pow(v, 1.0); } || requires { std::pow(v, 1.0); };
|
||||
}
|
||||
[[nodiscard]] constexpr quantity<pow<Num, Den>(R), Rep> pow(const quantity<R, Rep>& q) noexcept
|
||||
@ -328,7 +328,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
requires((!treat_as_floating_point<Rep>) || requires(Rep v) { floor(v); } || requires(Rep v) { std::floor(v); }) &&
|
||||
(equivalent(To, get_unit(R)) || requires {
|
||||
q.force_in(To);
|
||||
quantity_values<Rep>::one();
|
||||
representation_values<Rep>::one();
|
||||
})
|
||||
{
|
||||
const auto handle_signed_results = [&]<typename T>(const T& res) {
|
||||
@ -365,7 +365,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
requires((!treat_as_floating_point<Rep>) || requires(Rep v) { ceil(v); } || requires(Rep v) { std::ceil(v); }) &&
|
||||
(equivalent(To, get_unit(R)) || requires {
|
||||
q.force_in(To);
|
||||
quantity_values<Rep>::one();
|
||||
representation_values<Rep>::one();
|
||||
})
|
||||
{
|
||||
const auto handle_signed_results = [&]<typename T>(const T& res) {
|
||||
@ -404,7 +404,7 @@ template<Unit auto To, auto R, typename Rep>
|
||||
requires((!treat_as_floating_point<Rep>) || requires(Rep v) { round(v); } || requires(Rep v) { std::round(v); }) &&
|
||||
(equivalent(To, get_unit(R)) || requires {
|
||||
::mp_units::floor<To>(q);
|
||||
quantity_values<Rep>::one();
|
||||
representation_values<Rep>::one();
|
||||
})
|
||||
{
|
||||
if constexpr (equivalent(To, get_unit(R))) {
|
||||
@ -438,11 +438,11 @@ template<Unit auto To, auto R, typename Rep>
|
||||
template<Unit auto To, auto R, typename Rep>
|
||||
[[nodiscard]] constexpr QuantityOf<dimensionless / get_quantity_spec(R)> auto inverse(const quantity<R, Rep>& q)
|
||||
requires requires {
|
||||
quantity_values<Rep>::one();
|
||||
representation_values<Rep>::one();
|
||||
value_cast<To>(1 / q);
|
||||
}
|
||||
{
|
||||
return (quantity_values<Rep>::one() * one).force_in(To * quantity<R, Rep>::unit) / q;
|
||||
return (representation_values<Rep>::one() * one).force_in(To * quantity<R, Rep>::unit) / q;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user