diff --git a/src/core/include/mp_units/reference.h b/src/core/include/mp_units/reference.h index f32a2db9..f316c126 100644 --- a/src/core/include/mp_units/reference.h +++ b/src/core/include/mp_units/reference.h @@ -70,55 +70,73 @@ class quantity; * `2 / kmph`, `kmph * 3`, `kmph / 4`, `70 * isq::length[km] / isq:time[h]`. */ template -struct reference {}; +struct reference { + template + [[nodiscard]] friend consteval bool operator==(reference, reference) + { + return Q == Q2 && U == U2; + } -template -[[nodiscard]] consteval bool operator==(reference, reference) -{ - return Q1 == Q2 && U1 == U2; -} + template + [[nodiscard]] friend consteval bool operator==(reference, U2 u2) + { + return Q == get_quantity_spec(u2) && U == u2; + } -template -[[nodiscard]] consteval bool operator==(reference, U2 u2) -{ - return Q1 == get_quantity_spec(u2) && U1 == u2; -} + template + [[nodiscard]] friend consteval reference operator*(reference, reference) + { + return {}; + } -template -[[nodiscard]] consteval reference operator*(reference, reference) -{ - return {}; -} + template + [[nodiscard]] friend consteval reference operator*(reference, U2) + { + return {}; + } -template -[[nodiscard]] consteval reference operator*(reference, U2) -{ - return {}; -} + template + [[nodiscard]] friend consteval reference operator*(U1, reference) + { + return {}; + } -template -[[nodiscard]] consteval reference operator*(U1, reference) -{ - return {}; -} + template + [[nodiscard]] friend consteval reference operator/(reference, reference) + { + return {}; + } -template -[[nodiscard]] consteval reference operator/(reference, reference) -{ - return {}; -} + template + [[nodiscard]] friend consteval reference operator/(reference, U2) + { + return {}; + } -template -[[nodiscard]] consteval reference operator/(reference, U2) -{ - return {}; -} + template + [[nodiscard]] friend consteval reference operator/(U1, reference) + { + return {}; + } -template -[[nodiscard]] consteval reference operator/(U1, reference) -{ - return {}; -} + template + [[nodiscard]] friend consteval bool convertible_to(reference, reference) + { + return convertible_to(Q, Q2) && convertible_to(U, U2); + } + + template + [[nodiscard]] friend consteval bool convertible_to(reference, U2 u2) + { + return convertible_to(Q, get_quantity_spec(u2)) && convertible_to(U, u2); + } + + template + [[nodiscard]] friend consteval bool convertible_to(U1 u1, reference) + { + return convertible_to(get_quantity_spec(u1), Q) && convertible_to(u1, U); + } +}; template requires RepresentationOf, get_quantity_spec(R{}).character> @@ -129,24 +147,6 @@ template void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, Reference auto) = delete; -template -[[nodiscard]] consteval bool convertible_to(reference, reference) -{ - return convertible_to(Q1, Q2) && convertible_to(U1, U2); -} - -template -[[nodiscard]] consteval bool convertible_to(reference, U2 u2) -{ - return convertible_to(Q1, get_quantity_spec(u2)) && convertible_to(U1, u2); -} - -template -[[nodiscard]] consteval bool convertible_to(U1 u1, reference) -{ - return convertible_to(get_quantity_spec(u1), Q2) && convertible_to(u1, U2); -} - [[nodiscard]] consteval auto common_reference(AssociatedUnit auto u1, AssociatedUnit auto u2, AssociatedUnit auto... rest) requires requires {