refactor: std::assignable_from used in ValuePreservingTo concept

This commit is contained in:
Mateusz Pusz
2024-12-04 19:57:58 +01:00
parent 6cd7d388b1
commit 7e789bc1f1

View File

@@ -63,11 +63,11 @@ template<typename T>
concept IsFloatingPoint = treat_as_floating_point<T>; concept IsFloatingPoint = treat_as_floating_point<T>;
template<typename FromRep, typename ToRep, auto FromUnit = one, auto ToUnit = one> template<typename FromRep, typename ToRep, auto FromUnit = one, auto ToUnit = one>
concept ValuePreservingTo = concept ValuePreservingTo = Representation<std::remove_cvref_t<FromRep>> && Representation<ToRep> &&
requires(FromRep&& from, ToRep to) { Unit<MP_UNITS_REMOVE_CONST(decltype(FromUnit))> &&
{ to = std::forward<FromRep>(from) } -> std::same_as<ToRep&>; Unit<MP_UNITS_REMOVE_CONST(decltype(ToUnit))> && std::assignable_from<ToRep&, FromRep> &&
} && (IsFloatingPoint<ToRep> || (IsFloatingPoint<ToRep> || (!IsFloatingPoint<std::remove_cvref_t<FromRep>> &&
(!IsFloatingPoint<std::remove_cvref_t<FromRep>> && (integral_conversion_factor(FromUnit, ToUnit)))); (integral_conversion_factor(FromUnit, ToUnit))));
template<typename QFrom, typename QTo> template<typename QFrom, typename QTo>
concept QuantityConvertibleTo = concept QuantityConvertibleTo =