From cd2cd620bb5a727256837ae94f5fd5d13de4d11a Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 22 May 2023 17:54:14 +0200 Subject: [PATCH] refactor: constraints for `common_reference` improved --- src/core/include/mp_units/reference.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/include/mp_units/reference.h b/src/core/include/mp_units/reference.h index 1cf8afec..7d90287b 100644 --- a/src/core/include/mp_units/reference.h +++ b/src/core/include/mp_units/reference.h @@ -137,9 +137,12 @@ template void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, Reference auto) = delete; -[[nodiscard]] consteval auto common_reference(AssociatedUnit auto u1, AssociatedUnit auto u2, - AssociatedUnit auto... rest) +[[nodiscard]] consteval AssociatedUnit auto common_reference(AssociatedUnit auto u1, AssociatedUnit auto u2, + AssociatedUnit auto... rest) requires requires { + { + common_quantity_spec(get_quantity_spec(u1), get_quantity_spec(u2), get_quantity_spec(rest)...) + } -> QuantitySpec; { common_unit(u1, u2, rest...) } -> AssociatedUnit; @@ -149,7 +152,7 @@ void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, Referen } template -[[nodiscard]] consteval auto common_reference(R1 r1, R2 r2, Rest... rest) +[[nodiscard]] consteval Reference auto common_reference(R1 r1, R2 r2, Rest... rest) requires(!(AssociatedUnit && AssociatedUnit && (... && AssociatedUnit))) && requires { { common_quantity_spec(get_quantity_spec(r1), get_quantity_spec(r2), get_quantity_spec(rest)...)