mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
feat: ValuePreservingTo
extended with the explicit convertibility requirement
This commit is contained in:
@@ -60,8 +60,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 = requires(FromRep&& from, ToRep to) {
|
||||||
IsFloatingPoint<ToRep> || (!IsFloatingPoint<FromRep> && (integral_conversion_factor(FromUnit, ToUnit)));
|
{
|
||||||
|
to = std::forward<FromRep>(from)
|
||||||
|
} -> std::same_as<ToRep&>;
|
||||||
|
} && (IsFloatingPoint<ToRep> || (!IsFloatingPoint<FromRep> && (integral_conversion_factor(FromUnit, ToUnit))));
|
||||||
|
|
||||||
template<typename QFrom, typename QTo>
|
template<typename QFrom, typename QTo>
|
||||||
concept QuantityConvertibleTo =
|
concept QuantityConvertibleTo =
|
||||||
|
Reference in New Issue
Block a user