From 823fe26a1311a334fd8f954d7916580473d671a4 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 1 Aug 2023 11:55:39 +0200 Subject: [PATCH] feat: `quantity_point` binary operators are now constrained to prevent weakening of the origin --- src/core/include/mp-units/quantity_point.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 2e73f328..8edb6638 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -214,6 +214,8 @@ explicit quantity_point(QP) typename quantity_point_like_traits::rep>; template +// TODO simplify when gcc catches up + requires ReferenceOf, get_quantity_spec(R1)> [[nodiscard]] constexpr QuantityPoint auto operator+(const quantity_point& lhs, const quantity& rhs) requires requires { lhs.relative() + rhs; } @@ -224,6 +226,8 @@ template } template +// TODO simplify when gcc catches up + requires ReferenceOf, get_quantity_spec(R2)> [[nodiscard]] constexpr QuantityPoint auto operator+(const quantity& lhs, const quantity_point& rhs) requires requires { rhs + lhs; } @@ -232,6 +236,8 @@ template } template +// TODO simplify when gcc catches up + requires ReferenceOf, get_quantity_spec(R1)> [[nodiscard]] constexpr QuantityPoint auto operator-(const quantity_point& lhs, const quantity& rhs) requires requires { lhs.relative() - rhs; }