From 6b2606a8aaae8f2c39c4be6ae5abe13d98c8c7c7 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 13 Feb 2023 18:33:19 +0100 Subject: [PATCH] feat: explicit `quantity_spec` conversion support added to `quantity` constructor --- src/core/include/mp_units/quantity.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/include/mp_units/quantity.h b/src/core/include/mp_units/quantity.h index a33ec85c..543a261d 100644 --- a/src/core/include/mp_units/quantity.h +++ b/src/core/include/mp_units/quantity.h @@ -61,7 +61,8 @@ concept Harmonic = // exposition only template concept QuantityConvertibleTo = // exposition only - Quantity && Quantity && requires(QFrom q) { detail::sudo_cast(q); } && + Quantity && Quantity && explicitly_convertible_to(QFrom::quantity_spec, QTo::quantity_spec) && + requires(QFrom q) { detail::sudo_cast(q); } && (treat_as_floating_point || (!treat_as_floating_point && Harmonic)); @@ -122,7 +123,8 @@ public: quantity(quantity&&) = default; template Q> - constexpr explicit(false) quantity(const Q& q) : number_(detail::sudo_cast(q).number()) + constexpr explicit(!implicitly_convertible_to(Q::quantity_spec, quantity_spec)) quantity(const Q& q) : + number_(detail::sudo_cast(q).number()) { }