forked from mpusz/mp-units
refactor: quantity::count() renamed to quantity::number()
Resolves #259
This commit is contained in:
@@ -414,7 +414,7 @@ template<typename T>
|
||||
requires Dimension<typename quantity_like_traits<T>::dimension>;
|
||||
requires Unit<typename quantity_like_traits<T>::unit>;
|
||||
requires QuantityValue<typename quantity_like_traits<T>::rep>;
|
||||
{ quantity_like_traits<T>::count(q) } -> std::convertible_to<typename quantity_like_traits<T>::rep>;
|
||||
{ quantity_like_traits<T>::number(q) } -> std::convertible_to<typename quantity_like_traits<T>::rep>;
|
||||
}
|
||||
inline constexpr bool is_quantity_like<T> = true;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct quantity_like_traits<std::chrono::duration<Rep, Period>> {
|
||||
using dimension = isq::si::dim_time;
|
||||
using unit = downcast_unit<dimension, ratio(Period::num, Period::den)>;
|
||||
using rep = Rep;
|
||||
[[nodiscard]] static constexpr rep count(const std::chrono::duration<Rep, Period>& q) { return q.count(); }
|
||||
[[nodiscard]] static constexpr rep number(const std::chrono::duration<Rep, Period>& q) { return q.count(); }
|
||||
};
|
||||
|
||||
template<typename C, typename Rep, typename Period>
|
||||
|
||||
@@ -76,7 +76,7 @@ struct quantity_values {
|
||||
* @brief Provides support for external quantity-like types
|
||||
*
|
||||
* The type trait should provide the following nested type aliases: @c dimension, @c unit, @c rep,
|
||||
* and a static member function @c count(T) that will return the raw value of the quantity.
|
||||
* and a static member function @c number(T) that will return the raw value of the quantity.
|
||||
*
|
||||
* Usage example can be found in @c units/chrono.h header file.
|
||||
*
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace units {
|
||||
*/
|
||||
template<std::intmax_t Num, std::intmax_t Den = 1, Quantity Q>
|
||||
requires detail::non_zero<Den>
|
||||
[[nodiscard]] inline auto pow(const Q& q) noexcept requires requires { std::pow(q.count(), 1.0); }
|
||||
[[nodiscard]] inline auto pow(const Q& q) noexcept requires requires { std::pow(q.number(), 1.0); }
|
||||
{
|
||||
using rep = TYPENAME Q::rep;
|
||||
if constexpr (Num == 0) {
|
||||
@@ -50,7 +50,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Quantity Q>
|
||||
using dim = dimension_pow<typename Q::dimension, Num, Den>;
|
||||
using unit = downcast_unit<dim, pow<Num, Den>(Q::unit::ratio)>;
|
||||
return quantity<dim, unit, rep>(
|
||||
static_cast<rep>(std::pow(q.count(), static_cast<double>(Num) / static_cast<double>(Den))));
|
||||
static_cast<rep>(std::pow(q.number(), static_cast<double>(Num) / static_cast<double>(Den))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,12 +64,12 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Quantity Q>
|
||||
*/
|
||||
template<Quantity Q>
|
||||
[[nodiscard]] inline Quantity auto sqrt(const Q& q) noexcept
|
||||
requires requires { std::sqrt(q.count()); }
|
||||
requires requires { std::sqrt(q.number()); }
|
||||
{
|
||||
using dim = dimension_pow<typename Q::dimension, 1, 2>;
|
||||
using unit = downcast_unit<dim, sqrt(Q::unit::ratio)>;
|
||||
using rep = TYPENAME Q::rep;
|
||||
return quantity<dim, unit, rep>(static_cast<rep>(std::sqrt(q.count())));
|
||||
return quantity<dim, unit, rep>(static_cast<rep>(std::sqrt(q.number())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,12 +82,12 @@ template<Quantity Q>
|
||||
*/
|
||||
template<Quantity Q>
|
||||
[[nodiscard]] inline Quantity auto cbrt(const Q& q) noexcept
|
||||
requires requires { std::cbrt(q.count()); }
|
||||
requires requires { std::cbrt(q.number()); }
|
||||
{
|
||||
using dim = dimension_pow<typename Q::dimension, 1, 3>;
|
||||
using unit = downcast_unit<dim, cbrt(Q::unit::ratio)>;
|
||||
using rep = TYPENAME Q::rep;
|
||||
return quantity<dim, unit, rep>(static_cast<rep>(std::cbrt(q.count())));
|
||||
return quantity<dim, unit, rep>(static_cast<rep>(std::cbrt(q.number())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +101,7 @@ template<Quantity Q>
|
||||
template<typename U, typename Rep>
|
||||
[[nodiscard]] inline dimensionless<U, Rep> exp(const dimensionless<U, Rep>& q)
|
||||
{
|
||||
return quantity_cast<U>(dimensionless<one, Rep>(std::exp(quantity_cast<one>(q).count())));
|
||||
return quantity_cast<U>(dimensionless<one, Rep>(std::exp(quantity_cast<one>(q).number())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,9 +112,9 @@ template<typename U, typename Rep>
|
||||
*/
|
||||
template<typename D, typename U, typename Rep>
|
||||
[[nodiscard]] inline quantity<D, U, Rep> abs(const quantity<D, U, Rep>& q) noexcept
|
||||
requires requires { std::abs(q.count()); }
|
||||
requires requires { std::abs(q.number()); }
|
||||
{
|
||||
return quantity<D, U, Rep>(std::abs(q.count()));
|
||||
return quantity<D, U, Rep>(std::abs(q.number()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,31 +149,31 @@ public:
|
||||
quantity(const Value& v) : value_(v) {}
|
||||
|
||||
template<safe_castable_to_<quantity> Q>
|
||||
constexpr explicit(false) quantity(const Q& q) : value_(quantity_cast<quantity>(q).count()) {}
|
||||
constexpr explicit(false) quantity(const Q& q) : value_(quantity_cast<quantity>(q).number()) {}
|
||||
|
||||
template<QuantityLike Q>
|
||||
requires safe_castable_to_<quantity_like_type<Q>, quantity>
|
||||
constexpr explicit quantity(const Q& q) : quantity(quantity_like_type<Q>(quantity_like_traits<Q>::count(q))) {}
|
||||
constexpr explicit quantity(const Q& q) : quantity(quantity_like_type<Q>(quantity_like_traits<Q>::number(q))) {}
|
||||
|
||||
quantity& operator=(const quantity&) = default;
|
||||
quantity& operator=(quantity&&) = default;
|
||||
|
||||
// data access
|
||||
[[nodiscard]] constexpr rep count() const noexcept { return value_; }
|
||||
[[nodiscard]] constexpr rep number() const noexcept { return value_; }
|
||||
|
||||
// member unary operators
|
||||
[[nodiscard]] constexpr Quantity auto operator+() const
|
||||
requires requires(rep v) { { +v } -> std::common_with<rep>; }
|
||||
{
|
||||
using ret = quantity<D, U, decltype(+count())>;
|
||||
return ret(+count());
|
||||
using ret = quantity<D, U, decltype(+number())>;
|
||||
return ret(+number());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Quantity auto operator-() const
|
||||
requires std::regular_invocable<std::negate<>, rep>
|
||||
{
|
||||
using ret = quantity<D, U, decltype(-count())>;
|
||||
return ret(-count());
|
||||
using ret = quantity<D, U, decltype(-number())>;
|
||||
return ret(-number());
|
||||
}
|
||||
|
||||
constexpr quantity& operator++()
|
||||
@@ -205,14 +205,14 @@ public:
|
||||
constexpr quantity& operator+=(const quantity& q)
|
||||
requires requires(rep a, rep b) { { a += b } -> std::same_as<rep&>; }
|
||||
{
|
||||
value_ += q.count();
|
||||
value_ += q.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr quantity& operator-=(const quantity& q)
|
||||
requires requires(rep a, rep b) { { a -= b } -> std::same_as<rep&>; }
|
||||
{
|
||||
value_ -= q.count();
|
||||
value_ -= q.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
constexpr quantity& operator*=(const dimensionless<units::one, Rep2>& rhs)
|
||||
requires requires(rep a, const Rep2 b) { { a *= b } -> std::same_as<rep&>; }
|
||||
{
|
||||
value_ *= rhs.count();
|
||||
value_ *= rhs.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -243,8 +243,8 @@ public:
|
||||
constexpr quantity& operator/=(const dimensionless<units::one, Rep2>& rhs)
|
||||
requires requires(rep a, const Rep2 b) { { a /= b } -> std::same_as<rep&>; }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<Rep2>::zero());
|
||||
value_ /= rhs.count();
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<Rep2>::zero());
|
||||
value_ /= rhs.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -263,8 +263,8 @@ public:
|
||||
requires (!floating_point_<rep>) && (!floating_point_<Rep2>) &&
|
||||
requires(rep a, const Rep2 b) { { a %= b } -> std::same_as<rep&>; }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<Rep2>::zero());
|
||||
value_ %= rhs.count();
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<Rep2>::zero());
|
||||
value_ %= rhs.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -272,8 +272,8 @@ public:
|
||||
requires (!floating_point_<rep>) &&
|
||||
requires(rep a, rep b) { { a %= b } -> std::same_as<rep&>; }
|
||||
{
|
||||
gsl_ExpectsAudit(q.count() != quantity_values<rep>::zero());
|
||||
value_ %= q.count();
|
||||
gsl_ExpectsAudit(q.number() != quantity_values<rep>::zero());
|
||||
value_ %= q.number();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -284,14 +284,14 @@ public:
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
|
||||
requires invoke_result_convertible_to_<rep, std::plus<>, rep, Value>; } // when Clang catches up.
|
||||
{
|
||||
return units::quantity(lhs.count() + rhs);
|
||||
return units::quantity(lhs.number() + rhs);
|
||||
}
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs)
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
|
||||
requires invoke_result_convertible_to_<rep, std::plus<>, Value, rep>; } // when Clang catches up.
|
||||
{
|
||||
return units::quantity(lhs + rhs.count());
|
||||
return units::quantity(lhs + rhs.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -299,14 +299,14 @@ public:
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
|
||||
requires invoke_result_convertible_to_<rep, std::minus<>, rep, Value>; } // when Clang catches up.
|
||||
{
|
||||
return units::quantity(lhs.count() - rhs);
|
||||
return units::quantity(lhs.number() - rhs);
|
||||
}
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs)
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>; // TODO: Simplify
|
||||
requires invoke_result_convertible_to_<rep, std::minus<>, Value, rep>; } // when Clang catches up.
|
||||
{
|
||||
return units::quantity(lhs - rhs.count());
|
||||
return units::quantity(lhs - rhs.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
[[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v)
|
||||
{
|
||||
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, rep, Value>>;
|
||||
return ret(q.count() * v);
|
||||
return ret(q.number() * v);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -324,7 +324,7 @@ public:
|
||||
[[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q)
|
||||
{
|
||||
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, Value, rep>>;
|
||||
return ret(v * q.count());
|
||||
return ret(v * q.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -334,7 +334,7 @@ public:
|
||||
{
|
||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||
using ret = quantity<D, U, std::invoke_result_t<std::divides<>, rep, Value>>;
|
||||
return ret(q.count() / v);
|
||||
return ret(q.number() / v);
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -342,11 +342,11 @@ public:
|
||||
invoke_result_convertible_to_<rep, std::divides<>, const Value&, rep>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q)
|
||||
{
|
||||
gsl_ExpectsAudit(q.count() != quantity_values<rep>::zero());
|
||||
gsl_ExpectsAudit(q.number() != quantity_values<rep>::zero());
|
||||
using dim = dim_invert<D>;
|
||||
using ret_unit = downcast_unit<dim, inverse(U::ratio)>;
|
||||
using ret = quantity<dim, ret_unit, std::invoke_result_t<std::divides<>, Value, rep>>;
|
||||
return ret(v / q.count());
|
||||
return ret(v / q.number());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -356,15 +356,15 @@ public:
|
||||
{
|
||||
gsl_ExpectsAudit(v != quantity_values<Value>::zero());
|
||||
using ret = quantity<D, U, std::invoke_result_t<std::modulus<>, rep, Value>>;
|
||||
return ret(q.count() % v);
|
||||
return ret(q.number() % v);
|
||||
}
|
||||
|
||||
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs)
|
||||
requires (!floating_point_<rep>) && is_same_v<unit, units::one> &&
|
||||
invoke_result_convertible_to_<rep, std::modulus<>, rep, rep>
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<rep>::zero());
|
||||
return units::quantity(lhs.count() % rhs.count());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<rep>::zero());
|
||||
return units::quantity(lhs.number() % rhs.number());
|
||||
}
|
||||
|
||||
[[nodiscard]] friend constexpr auto operator<=>(const quantity& lhs, const quantity& rhs)
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
= default;
|
||||
#else
|
||||
{
|
||||
return lhs.count() <=> rhs.count();
|
||||
return lhs.number() <=> rhs.number();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -393,7 +393,7 @@ template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
[[nodiscard]] constexpr Quantity auto operator+(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
using ret = common_quantity_for<std::plus<>, Q1, Q2>;
|
||||
return ret(ret(lhs).count() + ret(rhs).count());
|
||||
return ret(ret(lhs).number() + ret(rhs).number());
|
||||
}
|
||||
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
@@ -401,22 +401,22 @@ template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
[[nodiscard]] constexpr Quantity auto operator-(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
using ret = common_quantity_for<std::minus<>, Q1, Q2>;
|
||||
return ret(ret(lhs).count() - ret(rhs).count());
|
||||
return ret(ret(lhs).number() - ret(rhs).number());
|
||||
}
|
||||
|
||||
template<Quantity Q1, Quantity Q2>
|
||||
requires quantity_value_for_<std::multiplies<>, typename Q1::rep, typename Q2::rep>
|
||||
[[nodiscard]] constexpr Quantity auto operator*(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
return detail::make_quantity<Q1::reference * Q2::reference>(lhs.count() * rhs.count());
|
||||
return detail::make_quantity<Q1::reference * Q2::reference>(lhs.number() * rhs.number());
|
||||
}
|
||||
|
||||
template<Quantity Q1, Quantity Q2>
|
||||
requires quantity_value_for_<std::divides<>, typename Q1::rep, typename Q2::rep>
|
||||
[[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<typename Q2::rep>::zero());
|
||||
return detail::make_quantity<Q1::reference / Q2::reference>(lhs.count() / rhs.count());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<typename Q2::rep>::zero());
|
||||
return detail::make_quantity<Q1::reference / Q2::reference>(lhs.number() / rhs.number());
|
||||
}
|
||||
|
||||
template<typename D1, typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
@@ -424,10 +424,10 @@ template<typename D1, typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
quantity_value_for_<std::modulus<>, Rep1, Rep2>
|
||||
[[nodiscard]] constexpr Quantity auto operator%(const quantity<D1, U1, Rep1>& lhs, const quantity<dim_one, U2, Rep2>& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<Rep2>::zero());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<Rep2>::zero());
|
||||
using unit = downcast_unit<D1, U1::ratio * U2::ratio>;
|
||||
using ret = quantity<D1, unit, std::invoke_result_t<std::modulus<>, Rep1, Rep2>>;
|
||||
return ret(lhs.count() % rhs.count());
|
||||
return ret(lhs.number() % rhs.number());
|
||||
}
|
||||
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
@@ -435,9 +435,9 @@ template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
quantity_value_for_<std::modulus<>, typename Q1::rep, typename Q2::rep>
|
||||
[[nodiscard]] constexpr Quantity auto operator%(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<typename Q2::rep>::zero());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<typename Q2::rep>::zero());
|
||||
using ret = common_quantity_for<std::modulus<>, Q1, Q2>;
|
||||
return ret(ret(lhs).count() % ret(rhs).count());
|
||||
return ret(ret(lhs).number() % ret(rhs).number());
|
||||
}
|
||||
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
@@ -445,7 +445,7 @@ template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
[[nodiscard]] constexpr auto operator<=>(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
using cq = common_quantity<Q1, Q2>;
|
||||
return cq(lhs).count() <=> cq(rhs).count();
|
||||
return cq(lhs).number() <=> cq(rhs).number();
|
||||
}
|
||||
|
||||
template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
@@ -453,7 +453,7 @@ template<Quantity Q1, QuantityEquivalentTo<Q1> Q2>
|
||||
[[nodiscard]] constexpr bool operator==(const Q1& lhs, const Q2& rhs)
|
||||
{
|
||||
using cq = common_quantity<Q1, Q2>;
|
||||
return cq(lhs).count() == cq(rhs).count();
|
||||
return cq(lhs).number() == cq(rhs).number();
|
||||
}
|
||||
|
||||
// type traits
|
||||
|
||||
@@ -121,17 +121,17 @@ template<Quantity To, typename D, typename U, scalable_with_<typename To::rep> R
|
||||
constexpr auto c_ratio = detail::cast_ratio<quantity<D, U, Rep>, To>;
|
||||
|
||||
if constexpr (treat_as_floating_point<rep_type>) {
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.count()) *
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.number()) *
|
||||
(static_cast<ratio_type>(c_ratio.num) * detail::fpow10<ratio_type>(c_ratio.exp) / static_cast<ratio_type>(c_ratio.den))));
|
||||
}
|
||||
else {
|
||||
if constexpr (c_ratio.exp > 0) {
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.count()) *
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.number()) *
|
||||
(static_cast<ratio_type>(c_ratio.num) * static_cast<ratio_type>(detail::ipow10(c_ratio.exp))) /
|
||||
static_cast<ratio_type>(c_ratio.den)));
|
||||
}
|
||||
else {
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.count()) *
|
||||
return To(static_cast<TYPENAME To::rep>(static_cast<rep_type>(q.number()) *
|
||||
static_cast<ratio_type>(c_ratio.num) /
|
||||
(static_cast<ratio_type>(c_ratio.den) * static_cast<ratio_type>(detail::ipow10(-c_ratio.exp)))));
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
constexpr quantity_kind& operator%=(const quantity_kind& qk)
|
||||
requires requires(quantity_type q) { q %= qk.common(); }
|
||||
{
|
||||
gsl_ExpectsAudit(qk.common().count() != quantity_values<rep>::zero());
|
||||
gsl_ExpectsAudit(qk.common().number() != quantity_values<rep>::zero());
|
||||
q_ %= qk.common();
|
||||
return *this;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
[[nodiscard]] friend constexpr QuantityKind auto operator/(const Value& v, const quantity_kind& qk)
|
||||
requires requires(quantity_type q) { { v / q } -> Quantity; }
|
||||
{
|
||||
gsl_ExpectsAudit(qk.common().count() != quantity_values<rep>::zero());
|
||||
gsl_ExpectsAudit(qk.common().number() != quantity_values<rep>::zero());
|
||||
return detail::downcasted_kind<quantity_kind>(v / qk.common());
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ template<QuantityKind QK, Quantity Q>
|
||||
[[nodiscard]] constexpr QuantityKind auto operator/(const QK& lhs, const Q& rhs)
|
||||
requires requires { lhs.common() / rhs; }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<typename Q::rep>::zero());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<typename Q::rep>::zero());
|
||||
return detail::downcasted_kind<QK>(lhs.common() / rhs);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ template<Quantity Q, QuantityKind QK>
|
||||
[[nodiscard]] constexpr QuantityKind auto operator/(const Q& lhs, const QK& rhs)
|
||||
requires requires { lhs / rhs.common(); }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.common().count() != quantity_values<typename QK::rep>::zero());
|
||||
gsl_ExpectsAudit(rhs.common().number() != quantity_values<typename QK::rep>::zero());
|
||||
return detail::downcasted_kind<QK>(lhs / rhs.common());
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ template<QuantityKind QK, Dimensionless D>
|
||||
[[nodiscard]] constexpr QuantityKind auto operator%(const QK& lhs, const D& rhs)
|
||||
requires requires { lhs.common() % rhs; }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.count() != quantity_values<typename D::rep>::zero());
|
||||
gsl_ExpectsAudit(rhs.number() != quantity_values<typename D::rep>::zero());
|
||||
return detail::make_quantity_kind<QK>(lhs.common() % rhs);
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ template<QuantityKind QK1, QuantityKindEquivalentTo<QK1> QK2>
|
||||
[[nodiscard]] constexpr QuantityKind auto operator%(const QK1& lhs, const QK2& rhs)
|
||||
requires requires { lhs.common() % rhs.common(); }
|
||||
{
|
||||
gsl_ExpectsAudit(rhs.common().count() != quantity_values<typename QK2::rep>::zero());
|
||||
gsl_ExpectsAudit(rhs.common().number() != quantity_values<typename QK2::rep>::zero());
|
||||
return detail::make_quantity_kind<QK1>(lhs.common() % rhs.common());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace detail {
|
||||
{
|
||||
std::vector<typename Q::rep> intervals_rep;
|
||||
intervals_rep.reserve(static_cast<size_t>(std::distance(first, last)));
|
||||
for (auto itr = first; itr != last; ++itr) { intervals_rep.push_back(itr->count()); }
|
||||
for (auto itr = first; itr != last; ++itr) { intervals_rep.push_back(itr->number()); }
|
||||
return intervals_rep;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace detail {
|
||||
{
|
||||
std::vector<typename Q::rep> bl_rep;
|
||||
bl_rep.reserve(bl.size());
|
||||
for (const Q& qty : bl) { bl_rep.push_back(qty.count()); }
|
||||
for (const Q& qty : bl) { bl_rep.push_back(qty.number()); }
|
||||
return bl_rep;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ struct uniform_int_distribution : public std::uniform_int_distribution<typename
|
||||
using base = TYPENAME std::uniform_int_distribution<rep>;
|
||||
|
||||
uniform_int_distribution() : base() {}
|
||||
uniform_int_distribution(const Q& a, const Q& b) : base(a.count(), b.count()) {}
|
||||
uniform_int_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -99,7 +99,7 @@ struct uniform_real_distribution : public std::uniform_real_distribution<typenam
|
||||
using base = TYPENAME std::uniform_real_distribution<rep>;
|
||||
|
||||
uniform_real_distribution() : base() {}
|
||||
uniform_real_distribution(const Q& a, const Q& b) : base(a.count(), b.count()) {}
|
||||
uniform_real_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -119,7 +119,7 @@ struct binomial_distribution : public std::binomial_distribution<typename Q::rep
|
||||
using base = TYPENAME std::binomial_distribution<rep>;
|
||||
|
||||
binomial_distribution() : base() {}
|
||||
binomial_distribution(const Q& t, double p) : base(t.count(), p) {}
|
||||
binomial_distribution(const Q& t, double p) : base(t.number(), p) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -138,7 +138,7 @@ struct negative_binomial_distribution : public std::negative_binomial_distributi
|
||||
using base = TYPENAME std::negative_binomial_distribution<rep>;
|
||||
|
||||
negative_binomial_distribution() : base() {}
|
||||
negative_binomial_distribution(const Q& k, double p) : base(k.count(), p) {}
|
||||
negative_binomial_distribution(const Q& k, double p) : base(k.number(), p) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -242,7 +242,7 @@ struct extreme_value_distribution : public std::extreme_value_distribution<typen
|
||||
using base = TYPENAME std::extreme_value_distribution<rep>;
|
||||
|
||||
extreme_value_distribution() : base() {}
|
||||
extreme_value_distribution(const Q& a, const rep& b) : base(a.count(), b) {}
|
||||
extreme_value_distribution(const Q& a, const rep& b) : base(a.number(), b) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -261,7 +261,7 @@ struct normal_distribution : public std::normal_distribution<typename Q::rep>
|
||||
using base = TYPENAME std::normal_distribution<rep>;
|
||||
|
||||
normal_distribution() : base() {}
|
||||
normal_distribution(const Q& mean, const Q& stddev) : base(mean.count(), stddev.count()) {}
|
||||
normal_distribution(const Q& mean, const Q& stddev) : base(mean.number(), stddev.number()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -281,7 +281,7 @@ struct lognormal_distribution : public std::lognormal_distribution<typename Q::r
|
||||
using base = TYPENAME std::lognormal_distribution<rep>;
|
||||
|
||||
lognormal_distribution() : base() {}
|
||||
lognormal_distribution(const Q& m, const Q& s) : base(m.count(), s.count()) {}
|
||||
lognormal_distribution(const Q& m, const Q& s) : base(m.number(), s.number()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -318,7 +318,7 @@ struct cauchy_distribution : public std::cauchy_distribution<typename Q::rep>
|
||||
using base = TYPENAME std::cauchy_distribution<rep>;
|
||||
|
||||
cauchy_distribution() : base() {}
|
||||
cauchy_distribution(const Q& a, const Q& b) : base(a.count(), b.count()) {}
|
||||
cauchy_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -416,7 +416,7 @@ public:
|
||||
|
||||
template <typename UnaryOperation>
|
||||
piecewise_constant_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) :
|
||||
base(nw, xmin.count(), xmax.count(), [fw](rep val) { return fw(Q(val)); }) {}
|
||||
base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
@@ -461,7 +461,7 @@ public:
|
||||
|
||||
template <typename UnaryOperation>
|
||||
piecewise_linear_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) :
|
||||
base(nw, xmin.count(), xmax.count(), [fw](rep val) { return fw(Q(val)); }) {}
|
||||
base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) {}
|
||||
|
||||
template<typename Generator>
|
||||
Q operator()(Generator& g) { return Q(base::operator()(g)); }
|
||||
|
||||
Reference in New Issue
Block a user