mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
feat: point_from
added to quantity_point
This commit is contained in:
@@ -139,6 +139,17 @@ public:
|
|||||||
quantity_point& operator=(const quantity_point&) = default;
|
quantity_point& operator=(const quantity_point&) = default;
|
||||||
quantity_point& operator=(quantity_point&&) = default;
|
quantity_point& operator=(quantity_point&&) = default;
|
||||||
|
|
||||||
|
template<PointOriginFor<quantity_spec> NewPO>
|
||||||
|
[[nodiscard]] constexpr QuantityPointOf<NewPO{}> auto point_from(NewPO origin) const
|
||||||
|
{
|
||||||
|
if constexpr (detail::is_derived_from_specialization_of_relative_point_origin<NewPO>) {
|
||||||
|
auto q = absolute() - origin.parent_origin.absolute();
|
||||||
|
return quantity_point<reference, NewPO{}, typename decltype(q)::rep>(std::move(q));
|
||||||
|
} else {
|
||||||
|
return quantity_point<reference, NewPO{}, Rep>(absolute());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// data access
|
// data access
|
||||||
#ifdef __cpp_explicit_this_parameter
|
#ifdef __cpp_explicit_this_parameter
|
||||||
template<typename Self>
|
template<typename Self>
|
||||||
|
Reference in New Issue
Block a user