refactor: convertible_to(U1, U2) renamed to convertible(U1, U2)
This commit is contained in:
1 parent
c892889901
commit
1e28c11cfc
6 files changed
+41
-40
No files matched your search
@@ -44,7 +44,7 @@ class quantity;
|
||||
* @tparam ToU a unit to use for a target quantity
|
||||
*/
|
||||
template<Unit auto ToU, auto R, typename Rep>
|
||||
requires(convertible_to(get_unit(R), ToU))
|
||||
requires(convertible(get_unit(R), ToU))
|
||||
[[nodiscard]] constexpr Quantity auto value_cast(const quantity<R, Rep>& q)
|
||||
{
|
||||
if constexpr (detail::is_specialization_of_reference<std::remove_const_t<decltype(R)>> ||
|
||||
|
||||
@@ -59,7 +59,7 @@ concept Harmonic = // exposition only
|
||||
template<typename QFrom, typename QTo>
|
||||
concept QuantityConvertibleTo = // exposition only
|
||||
Quantity<QFrom> && Quantity<QTo> && implicitly_convertible(QFrom::quantity_spec, QTo::quantity_spec) &&
|
||||
convertible_to(QFrom::unit, QTo::unit) && requires(QFrom q) { detail::sudo_cast<QTo>(q); } &&
|
||||
convertible(QFrom::unit, QTo::unit) && requires(QFrom q) { detail::sudo_cast<QTo>(q); } &&
|
||||
(treat_as_floating_point<typename QTo::rep> ||
|
||||
(!treat_as_floating_point<typename QFrom::rep> && Harmonic<QFrom::unit, QTo::unit>));
|
||||
|
||||
@@ -73,9 +73,11 @@ concept InvocableQuantities =
|
||||
typename Q2::rep> &&
|
||||
requires { common_reference(Q1::reference, Q2::reference); } &&
|
||||
std::constructible_from<quantity<common_reference(Q1::reference, Q2::reference),
|
||||
std::invoke_result_t<Func, typename Q1::rep, typename Q2::rep>>, Q1> &&
|
||||
std::invoke_result_t<Func, typename Q1::rep, typename Q2::rep>>,
|
||||
Q1> &&
|
||||
std::constructible_from<quantity<common_reference(Q1::reference, Q2::reference),
|
||||
std::invoke_result_t<Func, typename Q1::rep, typename Q2::rep>>, Q2>;
|
||||
std::invoke_result_t<Func, typename Q1::rep, typename Q2::rep>>,
|
||||
Q2>;
|
||||
|
||||
template<typename Func, Quantity Q1, Quantity Q2>
|
||||
requires detail::InvocableQuantities<Func, Q1, Q2>
|
||||
@@ -523,7 +525,6 @@ public:
|
||||
template<mp_units::Quantity Q, typename Value>
|
||||
requires(!mp_units::Quantity<Value>) && (Q::dimension == mp_units::dimension_one) && (Q::unit == mp_units::one) &&
|
||||
requires { typename common_type_t<typename Q::rep, Value>; }
|
||||
struct common_type<Value, Q> : common_type<Q, Value> {
|
||||
};
|
||||
struct common_type<Value, Q> : common_type<Q, Value> {};
|
||||
|
||||
} // namespace std
|
||||
@@ -73,7 +73,7 @@ struct reference {
|
||||
}
|
||||
|
||||
template<AssociatedUnit U2>
|
||||
[[nodiscard]] friend consteval reference<Q * get_quantity_spec(U2{}), U* U2{}> operator*(reference, U2)
|
||||
[[nodiscard]] friend consteval reference<Q * get_quantity_spec(U2{}), U * U2{}> operator*(reference, U2)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
@@ -103,21 +103,21 @@ struct reference {
|
||||
}
|
||||
|
||||
template<auto Q2, auto U2>
|
||||
[[nodiscard]] friend consteval bool convertible_to(reference, reference<Q2, U2>)
|
||||
[[nodiscard]] friend consteval bool convertible(reference, reference<Q2, U2>)
|
||||
{
|
||||
return implicitly_convertible(Q, Q2) && convertible_to(U, U2);
|
||||
return implicitly_convertible(Q, Q2) && convertible(U, U2);
|
||||
}
|
||||
|
||||
template<AssociatedUnit U2>
|
||||
[[nodiscard]] friend consteval bool convertible_to(reference, U2 u2)
|
||||
[[nodiscard]] friend consteval bool convertible(reference, U2 u2)
|
||||
{
|
||||
return implicitly_convertible(Q, get_quantity_spec(u2)) && convertible_to(U, u2);
|
||||
return implicitly_convertible(Q, get_quantity_spec(u2)) && convertible(U, u2);
|
||||
}
|
||||
|
||||
template<AssociatedUnit U1>
|
||||
[[nodiscard]] friend consteval bool convertible_to(U1 u1, reference)
|
||||
[[nodiscard]] friend consteval bool convertible(U1 u1, reference)
|
||||
{
|
||||
return implicitly_convertible(get_quantity_spec(u1), Q) && convertible_to(u1, U);
|
||||
return implicitly_convertible(get_quantity_spec(u1), Q) && convertible(u1, U);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ struct system_reference {
|
||||
static constexpr auto coherent_unit = CoU;
|
||||
|
||||
template<Unit U>
|
||||
requires(convertible_to(coherent_unit, U{}))
|
||||
requires(convertible(coherent_unit, U{}))
|
||||
[[nodiscard]] constexpr reference<quantity_spec, U{}> operator[](U) const
|
||||
{
|
||||
return {};
|
||||
|
||||
@@ -596,7 +596,7 @@ inline constexpr struct per_mille : named_unit<basic_symbol_text{"‰", "%o"}, m
|
||||
|
||||
|
||||
// convertible_to
|
||||
[[nodiscard]] consteval bool convertible_to(Unit auto u1, Unit auto u2)
|
||||
[[nodiscard]] consteval bool convertible(Unit auto from, Unit auto to)
|
||||
{
|
||||
return detail::have_same_canonical_reference_unit(u1, u2);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user