From 1328ae42459c4c590bcec6081a413ed738270d00 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 1 Aug 2023 22:06:15 +0200 Subject: [PATCH] feat: `point_from` added to `quantity_point` --- src/core/include/mp-units/quantity_point.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/include/mp-units/quantity_point.h b/src/core/include/mp-units/quantity_point.h index 8f0b6fcd..5f53eac3 100644 --- a/src/core/include/mp-units/quantity_point.h +++ b/src/core/include/mp-units/quantity_point.h @@ -139,6 +139,17 @@ public: quantity_point& operator=(const quantity_point&) = default; quantity_point& operator=(quantity_point&&) = default; + template NewPO> + [[nodiscard]] constexpr QuantityPointOf auto point_from(NewPO origin) const + { + if constexpr (detail::is_derived_from_specialization_of_relative_point_origin) { + auto q = absolute() - origin.parent_origin.absolute(); + return quantity_point(std::move(q)); + } else { + return quantity_point(absolute()); + } + } + // data access #ifdef __cpp_explicit_this_parameter template