[PR] rename macros to match naming conventions for workaround

This commit is contained in:
Jonas Hoppe
2024-09-04 09:37:41 +02:00
parent d18bb28a25
commit 712afc34b7
9 changed files with 68 additions and 76 deletions

View File

@@ -76,9 +76,9 @@ template<AssociatedUnit U>
template<AssociatedUnit U> template<AssociatedUnit U>
[[nodiscard]] consteval auto get_associated_quantity(U u) [[nodiscard]] consteval auto get_associated_quantity(U u)
{ {
constexpr bool all_kinds = all_are_kinds(MP_UNITS_IS_CONST_EXPR(u)); constexpr bool all_kinds = all_are_kinds(MP_UNITS_IS_CONST_EXPR_WORKAROUND(u));
if constexpr (all_kinds) if constexpr (all_kinds)
return kind_of<get_associated_quantity_impl(MP_UNITS_IS_CONST_EXPR(u))>; return kind_of<get_associated_quantity_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(u))>;
else else
return get_associated_quantity_impl(u); return get_associated_quantity_impl(u);
} }

View File

@@ -77,21 +77,6 @@
#define MP_UNITS_HOSTED __STDC_HOSTED__ #define MP_UNITS_HOSTED __STDC_HOSTED__
#endif #endif
#if MP_UNITS_COMP_MSVC
#define MP_UNITS_EXPRESSION(x) (x)
#define MP_UNITS_IS_VALUE(x) (x)
#define MP_UNITS_IS_CONST_EXPR(x) \
decltype(x) {}
#else
#define MP_UNITS_EXPRESSION(x) x
#define MP_UNITS_IS_VALUE(x) x
#define MP_UNITS_IS_CONST_EXPR(x) x
#endif
#if MP_UNITS_COMP_GCC #if MP_UNITS_COMP_GCC
#define MP_UNITS_REMOVE_CONST(expr) std::remove_const_t<expr> #define MP_UNITS_REMOVE_CONST(expr) std::remove_const_t<expr>
@@ -129,11 +114,18 @@ inline constexpr from_range_t from_range{};
#define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X) #define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X)
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) #define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X)
#define MP_UNITS_EXPRESSION_WORKAROUND(x) (x)
#define MP_UNITS_IS_VALUE_WORKAROUND(x) (x)
#define MP_UNITS_IS_CONST_EXPR_WORKAROUND(x) \
decltype(x) {}
#else #else
#define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X) X #define MP_UNITS_CONSTRAINED_AUTO_WORKAROUND(X) X
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X #define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X'
#define MP_UNITS_EXPRESSION_WORKAROUND(x) x
#define MP_UNITS_IS_VALUE_WORKAROUND(x) x
#define MP_UNITS_IS_CONST_EXPR_WORKAROUND(x) x
#endif #endif

View File

@@ -41,7 +41,7 @@ template<Reference R>
struct delta_ { struct delta_ {
template<typename Rep> template<typename Rep>
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character> requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
[[nodiscard]] constexpr quantity<MP_UNITS_EXPRESSION(R{}), std::remove_cvref_t<Rep>> operator()(Rep&& lhs) const [[nodiscard]] constexpr quantity< MP_UNITS_EXPRESSION_WORKAROUND(R{}), std::remove_cvref_t<Rep>> operator()(Rep&& lhs) const
{ {
return quantity{std::forward<Rep>(lhs), R{}}; return quantity{std::forward<Rep>(lhs), R{}};
} }
@@ -51,7 +51,7 @@ template<Reference R>
struct absolute_ { struct absolute_ {
template<typename Rep> template<typename Rep>
requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character> requires RepresentationOf<std::remove_cvref_t<Rep>, get_quantity_spec(R{}).character>
[[nodiscard]] constexpr quantity_point<MP_UNITS_EXPRESSION(R{}), default_point_origin(R{}), std::remove_cvref_t<Rep>> [[nodiscard]] constexpr quantity_point< MP_UNITS_EXPRESSION_WORKAROUND(R{}), default_point_origin(R{}), std::remove_cvref_t<Rep>>
operator()(Rep&& lhs) const operator()(Rep&& lhs) const
{ {
return quantity_point{quantity{std::forward<Rep>(lhs), R{}}}; return quantity_point{quantity{std::forward<Rep>(lhs), R{}}};

View File

@@ -54,7 +54,7 @@ template<PointOrigin PO>
struct point_origin_interface { struct point_origin_interface {
template<PointOrigin PO, Quantity Q> template<PointOrigin PO, Quantity Q>
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec> requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+( [[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep> operator+(
PO, Q&& q) PO, Q&& q)
{ {
return quantity_point{std::forward<Q>(q), PO{}}; return quantity_point{std::forward<Q>(q), PO{}};
@@ -62,7 +62,7 @@ struct point_origin_interface {
template<Quantity Q, PointOrigin PO> template<Quantity Q, PointOrigin PO>
requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec> requires ReferenceOf<std::remove_const_t<decltype(Q::reference)>, PO::quantity_spec>
[[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION(PO{}), typename Q::rep> operator+( [[nodiscard]] friend constexpr quantity_point<Q::reference, MP_UNITS_EXPRESSION_WORKAROUND(PO{}), typename Q::rep> operator+(
Q&& q, PO po) Q&& q, PO po)
{ {
return po + std::forward<Q>(q); return po + std::forward<Q>(q);

View File

@@ -673,10 +673,10 @@ template<QuantitySpec Q>
template<Dimension D1, Dimension D2> template<Dimension D1, Dimension D2>
[[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs) [[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs)
{ {
if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) || if constexpr (MP_UNITS_IS_CONST_EXPR_WORKAROUND(lhs) == MP_UNITS_IS_CONST_EXPR_WORKAROUND(rhs) ||
MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one) MP_UNITS_IS_CONST_EXPR_WORKAROUND(lhs) == dimension_one)
return false; return false;
else if constexpr (MP_UNITS_IS_CONST_EXPR(rhs) == dimension_one) else if constexpr (MP_UNITS_IS_CONST_EXPR_WORKAROUND(rhs) == dimension_one)
return true; return true;
else else
return detail::type_name<D1>() < detail::type_name<D2>(); return detail::type_name<D1>() < detail::type_name<D2>();
@@ -1345,21 +1345,21 @@ template<QuantitySpec From, QuantitySpec To>
using enum specs_convertible_result; using enum specs_convertible_result;
return res == no ? no : yes; return res == no ? no : yes;
}; };
if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(from_kind))> && if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind))> &&
NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(to_kind))>) || NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind))>) ||
get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) == get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))) get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind)) == get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind)))
return convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), MP_UNITS_IS_CONST_EXPR(to_kind)); return convertible_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind), MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind));
else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) > else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind)) >
get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))) get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind)))
return exploded_kind_result(convertible_impl( return exploded_kind_result(convertible_impl(
get_kind_tree_root( get_kind_tree_root(
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))>(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity), explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind)).quantity),
MP_UNITS_IS_CONST_EXPR(to_kind))); MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind)));
else else
return exploded_kind_result(convertible_impl( return exploded_kind_result(convertible_impl(
MP_UNITS_IS_CONST_EXPR(from_kind), MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind),
get_kind_tree_root( get_kind_tree_root(
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind))>(MP_UNITS_IS_CONST_EXPR(to_kind)).quantity))); explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind)).quantity)));
} }
template<NamedQuantitySpec From, NamedQuantitySpec To> template<NamedQuantitySpec From, NamedQuantitySpec To>
@@ -1377,11 +1377,11 @@ template<NamedQuantitySpec From, NamedQuantitySpec To>
else if constexpr (get_complexity(From{}) != get_complexity(To{})) { else if constexpr (get_complexity(From{}) != get_complexity(To{})) {
if constexpr (get_complexity(From{}) > get_complexity(To{})) if constexpr (get_complexity(From{}) > get_complexity(To{}))
return convertible_impl( return convertible_impl(
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to))>(MP_UNITS_IS_CONST_EXPR(from)).quantity, explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)).quantity,
MP_UNITS_IS_CONST_EXPR(to)); MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
else { else {
auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from))>(MP_UNITS_IS_CONST_EXPR(to)); auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity)); return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from), res.quantity));
} }
} }
} }
@@ -1397,31 +1397,31 @@ template<QuantitySpec From, QuantitySpec To>
else if constexpr (From::dimension != To::dimension) else if constexpr (From::dimension != To::dimension)
return no; return no;
else if constexpr (QuantityKindSpec<From> || QuantityKindSpec<To>) else if constexpr (QuantityKindSpec<From> || QuantityKindSpec<To>)
return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)), return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)),
get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to))); get_kind_tree_root(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to)));
else if constexpr (NestedQuantityKindSpecOf<get_kind_tree_root(To{}), from> && get_kind_tree_root(To{}) == To{}) else if constexpr (NestedQuantityKindSpecOf<get_kind_tree_root(To{}), from> && get_kind_tree_root(To{}) == To{})
return yes; return yes;
else if constexpr (NamedQuantitySpec<From> && NamedQuantitySpec<To>) else if constexpr (NamedQuantitySpec<From> && NamedQuantitySpec<To>)
return convertible_named(MP_UNITS_IS_CONST_EXPR(from), MP_UNITS_IS_CONST_EXPR(to)); return convertible_named(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from), MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
else if constexpr (DerivedQuantitySpec<From> && DerivedQuantitySpec<To>) else if constexpr (DerivedQuantitySpec<From> && DerivedQuantitySpec<To>)
return are_ingredients_convertible(from, MP_UNITS_IS_CONST_EXPR(to)); return are_ingredients_convertible(from, MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
else if constexpr (DerivedQuantitySpec<From>) { else if constexpr (DerivedQuantitySpec<From>) {
auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to))>(MP_UNITS_IS_CONST_EXPR(from)); auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from));
if constexpr (NamedQuantitySpec<decltype(res.quantity)>) if constexpr (NamedQuantitySpec<decltype(res.quantity)>)
return convertible_impl(res.quantity, MP_UNITS_IS_CONST_EXPR(to)); return convertible_impl(res.quantity, MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
else if constexpr (requires { MP_UNITS_IS_CONST_EXPR(to)._equation_; }) { else if constexpr (requires { MP_UNITS_IS_CONST_EXPR_WORKAROUND(to)._equation_; }) {
auto eq = explode_to_equation(MP_UNITS_IS_CONST_EXPR(to)); auto eq = explode_to_equation(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
return min(eq.result, convertible_impl(res.quantity, eq.equation)); return min(eq.result, convertible_impl(res.quantity, eq.equation));
} else } else
return are_ingredients_convertible(MP_UNITS_IS_CONST_EXPR(from), MP_UNITS_IS_CONST_EXPR(to)); return are_ingredients_convertible(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from), MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
} else if constexpr (DerivedQuantitySpec<To>) { } else if constexpr (DerivedQuantitySpec<To>) {
auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from))>(MP_UNITS_IS_CONST_EXPR(to)); auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
if constexpr (NamedQuantitySpec<decltype(res.quantity)>) if constexpr (NamedQuantitySpec<decltype(res.quantity)>)
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity)); return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from), res.quantity));
else if constexpr (requires { MP_UNITS_IS_CONST_EXPR(from)._equation_; }) else if constexpr (requires { MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)._equation_; })
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from)._equation_, res.quantity)); return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)._equation_, res.quantity));
else else
return min(res.result, are_ingredients_convertible(MP_UNITS_IS_CONST_EXPR(from), MP_UNITS_IS_CONST_EXPR(to))); return min(res.result, are_ingredients_convertible(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from), MP_UNITS_IS_CONST_EXPR_WORKAROUND(to)));
} }
// NOLINTEND(bugprone-branch-clone) // NOLINTEND(bugprone-branch-clone)
return no; return no;
@@ -1508,7 +1508,7 @@ MP_UNITS_EXPORT_BEGIN
template<QuantitySpec Q> template<QuantitySpec Q>
[[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q) [[nodiscard]] consteval detail::QuantityKindSpec auto get_kind(Q q)
{ {
return kind_of<detail::get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(q))>; return kind_of<detail::get_kind_tree_root(MP_UNITS_IS_CONST_EXPR_WORKAROUND(q))>;
} }
[[nodiscard]] consteval QuantitySpec auto common_quantity_spec(QuantitySpec auto q) { return q; } [[nodiscard]] consteval QuantitySpec auto common_quantity_spec(QuantitySpec auto q) { return q; }

View File

@@ -87,46 +87,46 @@ struct reference {
} }
template<typename Q2, typename U2> template<typename Q2, typename U2>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} * Q2{}), MP_UNITS_EXPRESSION(U{} * U2{})> [[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} * Q2{}), MP_UNITS_EXPRESSION_WORKAROUND(U{} * U2{})>
operator*(reference, reference<Q2, U2>) operator*(reference, reference<Q2, U2>)
{ {
return {}; return {};
} }
template<AssociatedUnit U2> template<AssociatedUnit U2>
[[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))), [[nodiscard]] friend consteval detail::reference_t<( MP_UNITS_EXPRESSION_WORKAROUND(Q{} * get_quantity_spec(U2{}))),
MP_UNITS_EXPRESSION(U{} * U2{})> MP_UNITS_EXPRESSION_WORKAROUND(U{} * U2{})>
operator*(reference, U2) operator*(reference, U2)
{ {
return {}; return {};
} }
template<AssociatedUnit U1> template<AssociatedUnit U1>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) * Q{}), [[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(get_quantity_spec(U1{}) * Q{}),
MP_UNITS_EXPRESSION(U1{} * U{})> MP_UNITS_EXPRESSION_WORKAROUND(U1{} * U{})>
operator*(U1, reference) operator*(U1, reference)
{ {
return {}; return {};
} }
template<typename Q2, typename U2> template<typename Q2, typename U2>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / Q2{}), MP_UNITS_EXPRESSION(U{} / U2{})> [[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} / Q2{}), MP_UNITS_EXPRESSION_WORKAROUND(U{} / U2{})>
operator/(reference, reference<Q2, U2>) operator/(reference, reference<Q2, U2>)
{ {
return {}; return {};
} }
template<AssociatedUnit U2> template<AssociatedUnit U2>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / get_quantity_spec(U2{})), [[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} / get_quantity_spec(U2{})),
MP_UNITS_EXPRESSION(U{} / U2{})> MP_UNITS_EXPRESSION_WORKAROUND(U{} / U2{})>
operator/(reference, U2) operator/(reference, U2)
{ {
return {}; return {};
} }
template<AssociatedUnit U1> template<AssociatedUnit U1>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) / Q{}), [[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(get_quantity_spec(U1{}) / Q{}),
MP_UNITS_EXPRESSION(U1{} / U{})> MP_UNITS_EXPRESSION_WORKAROUND(U1{} / U{})>
operator/(U1, reference) operator/(U1, reference)
{ {
return {}; return {};
@@ -296,9 +296,9 @@ template<Reference R1, Reference R2, Reference... Rest>
} }
{ {
return detail::reference_t< return detail::reference_t<
common_quantity_spec(get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r1)), get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r2)), common_quantity_spec(get_quantity_spec(MP_UNITS_IS_CONST_EXPR_WORKAROUND(r1)), get_quantity_spec(MP_UNITS_IS_CONST_EXPR_WORKAROUND(r2)),
get_quantity_spec(rest)...), get_quantity_spec(rest)...),
common_unit(get_unit(MP_UNITS_IS_CONST_EXPR(r1)), get_unit(MP_UNITS_IS_CONST_EXPR(r2)), get_unit(rest)...)>{}; common_unit(get_unit(MP_UNITS_IS_CONST_EXPR_WORKAROUND(r1)), get_unit(MP_UNITS_IS_CONST_EXPR_WORKAROUND(r2)), get_unit(rest)...)>{};
} }
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

View File

@@ -633,7 +633,7 @@ template<Unit From, Unit To>
template<Unit U1, Unit U2> template<Unit U1, Unit U2>
[[nodiscard]] consteval Unit auto common_unit(U1 u1, U2 u2) [[nodiscard]] consteval Unit auto common_unit(U1 u1, U2 u2)
requires(convertible(MP_UNITS_IS_CONST_EXPR(u1), MP_UNITS_IS_CONST_EXPR(u2))) requires(convertible(MP_UNITS_IS_CONST_EXPR_WORKAROUND(u1), MP_UNITS_IS_CONST_EXPR_WORKAROUND(u2)))
{ {
if constexpr (is_same_v<U1, U2>) if constexpr (is_same_v<U1, U2>)
return u1; return u1;

View File

@@ -127,13 +127,13 @@ namespace detail {
} // namespace detail } // namespace detail
template<QuantityOf<MP_UNITS_IS_VALUE(isq::time)> Q> template<QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::time)> Q>
[[nodiscard]] constexpr auto to_chrono_duration(const Q& q) [[nodiscard]] constexpr auto to_chrono_duration(const Q& q)
{ {
return std::chrono::duration<typename Q::rep, decltype(detail::as_ratio(get_canonical_unit(Q::unit).mag))>{q}; return std::chrono::duration<typename Q::rep, decltype(detail::as_ratio(get_canonical_unit(Q::unit).mag))>{q};
} }
template<QuantityPointOf<MP_UNITS_IS_VALUE(isq::time)> QP> template<QuantityPointOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::time)> QP>
requires is_specialization_of<std::remove_const_t<decltype(QP::absolute_point_origin)>, chrono_point_origin_> requires is_specialization_of<std::remove_const_t<decltype(QP::absolute_point_origin)>, chrono_point_origin_>
[[nodiscard]] constexpr auto to_chrono_time_point(const QP& qp) [[nodiscard]] constexpr auto to_chrono_time_point(const QP& qp)
{ {

View File

@@ -43,7 +43,7 @@ import std;
MP_UNITS_EXPORT MP_UNITS_EXPORT
namespace mp_units::si { namespace mp_units::si {
template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename Rep> template<ReferenceOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto R, typename Rep>
requires requires(Rep v) { sin(v); } || requires(Rep v) { std::sin(v); } requires requires(Rep v) { sin(v); } || requires(Rep v) { std::sin(v); }
[[nodiscard]] inline QuantityOf<dimensionless> auto sin(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<dimensionless> auto sin(const quantity<R, Rep>& q) noexcept
{ {
@@ -57,7 +57,7 @@ template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename R
return quantity{sin(q.numerical_value_in(radian)), one}; return quantity{sin(q.numerical_value_in(radian)), one};
} }
template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename Rep> template<ReferenceOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto R, typename Rep>
requires requires(Rep v) { cos(v); } || requires(Rep v) { std::cos(v); } requires requires(Rep v) { cos(v); } || requires(Rep v) { std::cos(v); }
[[nodiscard]] inline QuantityOf<dimensionless> auto cos(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<dimensionless> auto cos(const quantity<R, Rep>& q) noexcept
{ {
@@ -71,7 +71,7 @@ template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename R
return quantity{cos(q.numerical_value_in(radian)), one}; return quantity{cos(q.numerical_value_in(radian)), one};
} }
template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename Rep> template<ReferenceOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto R, typename Rep>
requires requires(Rep v) { tan(v); } || requires(Rep v) { std::tan(v); } requires requires(Rep v) { tan(v); } || requires(Rep v) { std::tan(v); }
[[nodiscard]] inline QuantityOf<dimensionless> auto tan(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<dimensionless> auto tan(const quantity<R, Rep>& q) noexcept
{ {
@@ -87,7 +87,7 @@ template<ReferenceOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto R, typename R
template<ReferenceOf<dimensionless> auto R, typename Rep> template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { asin(v); } || requires(Rep v) { std::asin(v); } requires requires(Rep v) { asin(v); } || requires(Rep v) { std::asin(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto asin(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto asin(const quantity<R, Rep>& q) noexcept
{ {
using std::asin; using std::asin;
if constexpr (!treat_as_floating_point<Rep>) { if constexpr (!treat_as_floating_point<Rep>) {
@@ -101,7 +101,7 @@ template<ReferenceOf<dimensionless> auto R, typename Rep>
template<ReferenceOf<dimensionless> auto R, typename Rep> template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { acos(v); } || requires(Rep v) { std::acos(v); } requires requires(Rep v) { acos(v); } || requires(Rep v) { std::acos(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto acos(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto acos(const quantity<R, Rep>& q) noexcept
{ {
using std::acos; using std::acos;
if constexpr (!treat_as_floating_point<Rep>) { if constexpr (!treat_as_floating_point<Rep>) {
@@ -115,7 +115,7 @@ template<ReferenceOf<dimensionless> auto R, typename Rep>
template<ReferenceOf<dimensionless> auto R, typename Rep> template<ReferenceOf<dimensionless> auto R, typename Rep>
requires requires(Rep v) { atan(v); } || requires(Rep v) { std::atan(v); } requires requires(Rep v) { atan(v); } || requires(Rep v) { std::atan(v); }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto atan(const quantity<R, Rep>& q) noexcept [[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto atan(const quantity<R, Rep>& q) noexcept
{ {
using std::atan; using std::atan;
if constexpr (!treat_as_floating_point<Rep>) { if constexpr (!treat_as_floating_point<Rep>) {
@@ -132,7 +132,7 @@ template<auto R1, typename Rep1, auto R2, typename Rep2>
common_reference(R1, R2); common_reference(R1, R2);
requires requires { atan2(v1, v2); } || requires { std::atan2(v1, v2); }; requires requires { atan2(v1, v2); } || requires { std::atan2(v1, v2); };
} }
[[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE(isq::angular_measure)> auto atan2( [[nodiscard]] inline QuantityOf<MP_UNITS_IS_VALUE_WORKAROUND(isq::angular_measure)> auto atan2(
const quantity<R1, Rep1>& y, const quantity<R2, Rep2>& x) noexcept const quantity<R1, Rep1>& y, const quantity<R2, Rep2>& x) noexcept
{ {
constexpr auto ref = common_reference(R1, R2); constexpr auto ref = common_reference(R1, R2);