refactor: zeroth_point_origin() renamed to default_point_origin() and implicit_zeroth_point_origin renamed to zeroth_point_origin

This commit is contained in:
Mateusz Pusz committed 2023-12-22 17:29:02 +01:00
1 parent bf51bfc96f
commit be1705bc4a
4 files changed
+83 -93

No files matched your search

+14 -14
View File
@@ -64,23 +64,23 @@ struct relative_point_origin {
};
template<QuantitySpec auto QS>
struct implicit_zeroth_point_origin_ : absolute_point_origin<implicit_zeroth_point_origin_<QS>, QS> {};
struct zeroth_point_origin_ : absolute_point_origin<zeroth_point_origin_<QS>, QS> {};
template<QuantitySpec auto QS>
inline constexpr implicit_zeroth_point_origin_<QS> implicit_zeroth_point_origin;
inline constexpr zeroth_point_origin_<QS> zeroth_point_origin;
namespace detail {
template<PointOrigin PO>
inline constexpr bool is_specialization_of_implicit_zeroth_point_origin = false;
inline constexpr bool is_specialization_of_zeroth_point_origin = false;
template<auto QS>
inline constexpr bool is_specialization_of_implicit_zeroth_point_origin<implicit_zeroth_point_origin_<QS>> = true;
inline constexpr bool is_specialization_of_zeroth_point_origin<zeroth_point_origin_<QS>> = true;
template<PointOrigin PO>
[[nodiscard]] consteval bool is_implicit_zeroth_point_origin(PO)
[[nodiscard]] consteval bool is_zeroth_point_origin(PO)
{
return is_specialization_of_implicit_zeroth_point_origin<PO>;
return is_specialization_of_zeroth_point_origin<PO>;
}
} // namespace detail
@@ -90,7 +90,7 @@ template<PointOrigin PO1, PointOrigin PO2>
{
if constexpr (detail::AbsolutePointOrigin<PO1> && detail::AbsolutePointOrigin<PO2>)
return is_same_v<typename PO1::_type_, typename PO2::_type_> ||
(detail::is_implicit_zeroth_point_origin(po1) && detail::is_implicit_zeroth_point_origin(po2) &&
(detail::is_zeroth_point_origin(po1) && detail::is_zeroth_point_origin(po2) &&
interconvertible(po1.quantity_spec, po2.quantity_spec));
else if constexpr (detail::RelativePointOrigin<PO1> && detail::RelativePointOrigin<PO2>)
return PO1::quantity_point == PO2::quantity_point;
@@ -103,12 +103,12 @@ template<PointOrigin PO1, PointOrigin PO2>
}
template<Reference R>
[[nodiscard]] consteval PointOriginFor<get_quantity_spec(R{})> auto zeroth_point_origin(R)
[[nodiscard]] consteval PointOriginFor<get_quantity_spec(R{})> auto default_point_origin(R)
{
if constexpr (requires { get_unit(R{}).point_origin; })
return get_unit(R{}).point_origin;
else
return implicit_zeroth_point_origin<get_quantity_spec(R{})>;
return zeroth_point_origin<get_quantity_spec(R{})>;
}
namespace detail {
@@ -133,7 +133,7 @@ template<PointOrigin PO>
* @tparam PO a type that represents the origin point from which the quantity point is measured from
* @tparam Rep a type to be used to represent values of a quantity point
*/
template<Reference auto R, PointOriginFor<get_quantity_spec(R)> auto PO = zeroth_point_origin(R),
template<Reference auto R, PointOriginFor<get_quantity_spec(R)> auto PO = default_point_origin(R),
RepresentationOf<get_quantity_spec(R).character> Rep = double>
class quantity_point {
public:
@@ -169,7 +169,7 @@ public:
template<typename Q>
requires QuantityOf<std::remove_cvref_t<Q>, get_quantity_spec(R)> && std::constructible_from<quantity_type, Q> &&
(point_origin == zeroth_point_origin(R)) && (implicitly_convertible(Q::quantity_spec, quantity_spec))
(point_origin == default_point_origin(R)) && (implicitly_convertible(Q::quantity_spec, quantity_spec))
constexpr explicit quantity_point(Q&& q) : quantity_from_origin_is_an_implementation_detail_(std::forward<Q>(q))
{
}
@@ -377,7 +377,7 @@ public:
// CTAD
template<Quantity Q>
quantity_point(Q q) -> quantity_point<Q::reference, zeroth_point_origin(Q::reference), typename Q::rep>;
quantity_point(Q q) -> quantity_point<Q::reference, default_point_origin(Q::reference), typename Q::rep>;
template<Quantity Q, PointOriginFor<Q::quantity_spec> PO>
quantity_point(Q q, PO) -> quantity_point<Q::reference, PO{}, typename Q::rep>;
@@ -396,7 +396,7 @@ template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2>
const quantity<R2, Rep2>& q)
requires requires { qp.quantity_ref_from(PO1) + q; }
{
if constexpr (detail::is_implicit_zeroth_point_origin(PO1))
if constexpr (detail::is_zeroth_point_origin(PO1))
return quantity_point{qp.quantity_ref_from(PO1) + q};
else
return quantity_point{qp.quantity_ref_from(PO1) + q, PO1};
@@ -433,7 +433,7 @@ template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2>
const quantity<R2, Rep2>& q)
requires requires { qp.quantity_ref_from(PO1) - q; }
{
if constexpr (detail::is_implicit_zeroth_point_origin(PO1))
if constexpr (detail::is_zeroth_point_origin(PO1))
return quantity_point{qp.quantity_ref_from(PO1) - q};
else
return quantity_point{qp.quantity_ref_from(PO1) - q, PO1};