diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index 900cf190..8d37e151 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -59,7 +59,7 @@ template requires(!AssociatedUnit) || UnitOf [[nodiscard]] consteval Reference auto make_reference(QS, U u) { - if constexpr (QuantityKindSpec) + if constexpr (requires { requires(get_quantity_spec(U{}) == QS{}); }) return u; else return reference{}; diff --git a/test/static/reference_test.cpp b/test/static/reference_test.cpp index 09758aac..fce21a0b 100644 --- a/test/static/reference_test.cpp +++ b/test/static/reference_test.cpp @@ -378,4 +378,14 @@ static_assert(invalid_comparison) static_assert(invalid_comparison); static_assert(invalid_comparison); +// make_reference +static_assert(is_of_type>); +static_assert(is_of_type>); +static_assert(is_of_type, metre), metre_>); +static_assert(is_of_type); +static_assert(is_of_type); +static_assert(is_of_type, hertz), hertz_>); +static_assert(is_of_type); +static_assert(is_of_type, watt), reference, watt_>>); + } // namespace