diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index b23a37e4..e86b1a88 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -24,6 +24,7 @@ #pragma once // IWYU pragma: private, include +#include #include #include #include @@ -229,7 +230,12 @@ public: template requires(U{} == unit) - constexpr const rep&& numerical_value_ref_in(U) const&& noexcept = delete; + constexpr const rep&& numerical_value_ref_in(U) const&& noexcept +#if __cpp_deleted_function + = delete("Can't form a reference to a temporary"); +#else + = delete; +#endif template U> requires requires(quantity q) { q.in(U{}); } diff --git a/src/core/include/mp-units/framework/quantity_point.h b/src/core/include/mp-units/framework/quantity_point.h index 35288afb..70c3ce13 100644 --- a/src/core/include/mp-units/framework/quantity_point.h +++ b/src/core/include/mp-units/framework/quantity_point.h @@ -23,6 +23,7 @@ #pragma once // IWYU pragma: private, include +#include #include #include #include @@ -241,7 +242,12 @@ public: template requires(PO2{} == point_origin) - constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept = delete; + constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept +#if __cpp_deleted_function + = delete("Can't form a reference to a temporary"); +#else + = delete; +#endif template requires requires { quantity_point{} - PO2{}; } diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index aae947ba..9d637909 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -240,12 +240,22 @@ template template requires RepresentationOf, get_quantity_spec(R{}).character> // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) -constexpr auto operator*(R, Rep&&) = delete; +constexpr auto operator*(R, Rep&&) +#if __cpp_deleted_function + = delete("To create a `quantity` or `quantity_point` use `Rep * R`"); +#else + = delete; +#endif template requires RepresentationOf, get_quantity_spec(R{}).character> // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) -constexpr auto operator/(R, Rep&&) = delete; +constexpr auto operator/(R, Rep&&) +#if __cpp_deleted_function + = delete("To create a `quantity` or `quantity_point` use `Rep / R`"); +#else + = delete; +#endif template requires Quantity> diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index f5c140a7..1b6cfcaa 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -449,7 +449,12 @@ template return scaled_unit{}; } -[[nodiscard]] consteval Unit auto operator*(Unit auto, Magnitude auto) = delete; +[[nodiscard]] consteval Unit auto operator*(Unit auto, Magnitude auto) +#if __cpp_deleted_function + = delete("To scale a unit use `mag * unit` syntax"); +#else + = delete; +#endif /** * Returns the result of multiplication with an inverse unit.