diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 014e9e8e..b23a37e4 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -166,6 +166,14 @@ public: { } + template + requires(!DeltaReference) + constexpr quantity(Value&&, R2) + { + static_assert(false, + "References using offset units (e.g., temperatures) must be explicitly qualified with `delta`"); + } + template Q> // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(!std::convertible_to) quantity(const Q& q) : @@ -433,6 +441,11 @@ template requires RepresentationOf quantity(Value v, R) -> quantity; +// the below is needed only to fire static_asserts in the constructor +template + requires(!DeltaReference) && RepresentationOf +quantity(Value v, R) -> quantity; + template explicit( is_specialization_of::to_numerical_value(std::declval())), convert_explicitly>) diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index d5b980d7..aae947ba 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -219,6 +219,24 @@ operator/(Rep&& lhs, R) return quantity_point{std::forward(lhs) * delta}; } +template + requires(!DeltaReference) && RepresentationOf, get_quantity_spec(R{}).character> +[[noreturn]] constexpr auto operator*(Rep&&, R) +{ + static_assert( + false, + "References using offset units (e.g., temperatures) must be explicitly qualified with `delta` or `absolute`"); +} + +template + requires(!DeltaReference) && RepresentationOf, get_quantity_spec(R{}).character> +[[noreturn]] constexpr auto operator/(Rep&&, R) +{ + static_assert( + false, + "References using offset units (e.g., temperatures) must be explicitly qualified with `delta` or `absolute`"); +} + template requires RepresentationOf, get_quantity_spec(R{}).character> // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)