[PR] rename macros to match naming conventions for workaround

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

No files matched your search

@@ -76,9 +76,9 @@ template<AssociatedUnit U>
template<AssociatedUnit 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)
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
return get_associated_quantity_impl(u);
}
+8 -16
View File
@@ -77,21 +77,6 @@
#define MP_UNITS_HOSTED __STDC_HOSTED__
#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
#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_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
#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
@@ -41,7 +41,7 @@ template<Reference R>
struct delta_ {
template<typename Rep>
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{}};
}
@@ -51,7 +51,7 @@ template<Reference R>
struct absolute_ {
template<typename Rep>
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
{
return quantity_point{quantity{std::forward<Rep>(lhs), R{}}};
@@ -54,7 +54,7 @@ template<PointOrigin PO>
struct point_origin_interface {
template<PointOrigin PO, Quantity Q>
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)
{
return quantity_point{std::forward<Q>(q), PO{}};
@@ -62,7 +62,7 @@ struct point_origin_interface {
template<Quantity Q, PointOrigin PO>
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)
{
return po + std::forward<Q>(q);
@@ -673,10 +673,10 @@ template<QuantitySpec Q>
template<Dimension D1, Dimension D2>
[[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs)
{
if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) ||
MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one)
if constexpr (MP_UNITS_IS_CONST_EXPR_WORKAROUND(lhs) == MP_UNITS_IS_CONST_EXPR_WORKAROUND(rhs) ||
MP_UNITS_IS_CONST_EXPR_WORKAROUND(lhs) == dimension_one)
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;
else
return detail::type_name<D1>() < detail::type_name<D2>();
@@ -1345,21 +1345,21 @@ template<QuantitySpec From, QuantitySpec To>
using enum specs_convertible_result;
return res == no ? no : yes;
};
if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(from_kind))> &&
NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR(to_kind))>) ||
get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) == get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind)))
return convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), MP_UNITS_IS_CONST_EXPR(to_kind));
else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) >
get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind)))
if constexpr ((NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind))> &&
NamedQuantitySpec<decltype(MP_UNITS_IS_CONST_EXPR_WORKAROUND(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_WORKAROUND(from_kind), MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind));
else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from_kind)) >
get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to_kind)))
return exploded_kind_result(convertible_impl(
get_kind_tree_root(
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))>(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity),
MP_UNITS_IS_CONST_EXPR(to_kind)));
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_WORKAROUND(to_kind)));
else
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(
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>
@@ -1377,11 +1377,11 @@ template<NamedQuantitySpec From, NamedQuantitySpec To>
else if constexpr (get_complexity(From{}) != get_complexity(To{})) {
if constexpr (get_complexity(From{}) > get_complexity(To{}))
return convertible_impl(
explode<get_complexity(MP_UNITS_IS_CONST_EXPR(to))>(MP_UNITS_IS_CONST_EXPR(from)).quantity,
MP_UNITS_IS_CONST_EXPR(to));
explode<get_complexity(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to))>(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)).quantity,
MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
else {
auto res = explode<get_complexity(MP_UNITS_IS_CONST_EXPR(from))>(MP_UNITS_IS_CONST_EXPR(to));
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity));
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_WORKAROUND(from), res.quantity));
}
}
}
@@ -1397,31 +1397,31 @@ template<QuantitySpec From, QuantitySpec To>
else if constexpr (From::dimension != To::dimension)
return no;
else if constexpr (QuantityKindSpec<From> || QuantityKindSpec<To>)
return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)),
get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to)));
return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)),
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{})
return yes;
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>)
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>) {
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)>)
return convertible_impl(res.quantity, MP_UNITS_IS_CONST_EXPR(to));
else if constexpr (requires { MP_UNITS_IS_CONST_EXPR(to)._equation_; }) {
auto eq = explode_to_equation(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_WORKAROUND(to)._equation_; }) {
auto eq = explode_to_equation(MP_UNITS_IS_CONST_EXPR_WORKAROUND(to));
return min(eq.result, convertible_impl(res.quantity, eq.equation));
} 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>) {
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)>)
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity));
else if constexpr (requires { MP_UNITS_IS_CONST_EXPR(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), res.quantity));
else if constexpr (requires { MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)._equation_; })
return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR_WORKAROUND(from)._equation_, res.quantity));
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)
return no;
@@ -1508,7 +1508,7 @@ MP_UNITS_EXPORT_BEGIN
template<QuantitySpec 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; }
+12 -12
View File
@@ -87,46 +87,46 @@ struct reference {
}
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>)
{
return {};
}
template<AssociatedUnit U2>
[[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))),
MP_UNITS_EXPRESSION(U{} * U2{})>
[[nodiscard]] friend consteval detail::reference_t<( MP_UNITS_EXPRESSION_WORKAROUND(Q{} * get_quantity_spec(U2{}))),
MP_UNITS_EXPRESSION_WORKAROUND(U{} * U2{})>
operator*(reference, U2)
{
return {};
}
template<AssociatedUnit U1>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) * Q{}),
MP_UNITS_EXPRESSION(U1{} * U{})>
[[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(get_quantity_spec(U1{}) * Q{}),
MP_UNITS_EXPRESSION_WORKAROUND(U1{} * U{})>
operator*(U1, reference)
{
return {};
}
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>)
{
return {};
}
template<AssociatedUnit U2>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(Q{} / get_quantity_spec(U2{})),
MP_UNITS_EXPRESSION(U{} / U2{})>
[[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(Q{} / get_quantity_spec(U2{})),
MP_UNITS_EXPRESSION_WORKAROUND(U{} / U2{})>
operator/(reference, U2)
{
return {};
}
template<AssociatedUnit U1>
[[nodiscard]] friend consteval detail::reference_t<MP_UNITS_EXPRESSION(get_quantity_spec(U1{}) / Q{}),
MP_UNITS_EXPRESSION(U1{} / U{})>
[[nodiscard]] friend consteval detail::reference_t< MP_UNITS_EXPRESSION_WORKAROUND(get_quantity_spec(U1{}) / Q{}),
MP_UNITS_EXPRESSION_WORKAROUND(U1{} / U{})>
operator/(U1, reference)
{
return {};
@@ -296,9 +296,9 @@ template<Reference R1, Reference R2, Reference... Rest>
}
{
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)...),
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
+1 -1
View File
@@ -633,7 +633,7 @@ template<Unit From, Unit To>
template<Unit U1, Unit 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>)
return u1;