From 0dfd323c4b3346009a3ab72685fccd322815d1fe Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sun, 14 Jul 2024 18:06:02 +0200 Subject: [PATCH] feat: `ValuePreservingTo` extended with the explicit convertibility requirement --- src/core/include/mp-units/framework/quantity.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 936c227e..279e81a7 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -60,8 +60,11 @@ template concept IsFloatingPoint = treat_as_floating_point; template -concept ValuePreservingTo = - IsFloatingPoint || (!IsFloatingPoint && (integral_conversion_factor(FromUnit, ToUnit))); +concept ValuePreservingTo = requires(FromRep&& from, ToRep to) { + { + to = std::forward(from) + } -> std::same_as; +} && (IsFloatingPoint || (!IsFloatingPoint && (integral_conversion_factor(FromUnit, ToUnit)))); template concept QuantityConvertibleTo =