refactor: more workarounds for gcc-12

This commit is contained in:
Mateusz Pusz
2024-06-01 13:03:20 +02:00
parent 16493ee99a
commit 1c5b8de627
8 changed files with 45 additions and 45 deletions

View File

@@ -136,7 +136,7 @@ concept one_of = (false || ... || std::same_as<T, Ts>);
template<typename T, auto... Vs> template<typename T, auto... Vs>
[[nodiscard]] consteval bool contains() [[nodiscard]] consteval bool contains()
{ {
return (false || ... || is_same_v<decltype(Vs), T>); return (false || ... || is_same_v<MP_UNITS_REMOVE_CONST(decltype(Vs)), T>);
} }
template<template<typename...> typename T, typename... Ts> template<template<typename...> typename T, typename... Ts>
@@ -160,7 +160,7 @@ template<typename T, std::same_as<T> auto V>
template<typename T, auto V1, auto V2, auto... Vs> template<typename T, auto V1, auto V2, auto... Vs>
[[nodiscard]] consteval auto get() [[nodiscard]] consteval auto get()
{ {
if constexpr (is_same_v<T, decltype(V1)>) if constexpr (is_same_v<T, MP_UNITS_REMOVE_CONST(decltype(V1))>)
return V1; return V1;
else else
return get<T, V2, Vs...>(); return get<T, V2, Vs...>();

View File

@@ -386,7 +386,7 @@ explicit(
template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2> template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2>
// TODO simplify when gcc catches up // TODO simplify when gcc catches up
requires ReferenceOf<decltype(R2), PO1.quantity_spec> requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype(R2)), PO1.quantity_spec>
[[nodiscard]] constexpr QuantityPoint auto operator+(const quantity_point<R1, PO1, Rep1>& qp, [[nodiscard]] constexpr QuantityPoint auto operator+(const quantity_point<R1, PO1, Rep1>& qp,
const quantity<R2, Rep2>& q) const quantity<R2, Rep2>& q)
requires requires { qp.quantity_ref_from(PO1) + q; } requires requires { qp.quantity_ref_from(PO1) + q; }
@@ -399,7 +399,7 @@ template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2>
template<auto R1, typename Rep1, auto R2, auto PO2, typename Rep2> template<auto R1, typename Rep1, auto R2, auto PO2, typename Rep2>
// TODO simplify when gcc catches up // TODO simplify when gcc catches up
requires ReferenceOf<decltype(R1), PO2.quantity_spec> requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype(R1)), PO2.quantity_spec>
[[nodiscard]] constexpr QuantityPoint auto operator+(const quantity<R1, Rep1>& q, [[nodiscard]] constexpr QuantityPoint auto operator+(const quantity<R1, Rep1>& q,
const quantity_point<R2, PO2, Rep2>& qp) const quantity_point<R2, PO2, Rep2>& qp)
requires requires { q + qp.quantity_ref_from(PO2); } requires requires { q + qp.quantity_ref_from(PO2); }
@@ -423,7 +423,7 @@ template<Quantity Q, PointOrigin PO>
template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2> template<auto R1, auto PO1, typename Rep1, auto R2, typename Rep2>
// TODO simplify when gcc catches up // TODO simplify when gcc catches up
requires ReferenceOf<decltype(R2), PO1.quantity_spec> requires ReferenceOf<MP_UNITS_REMOVE_CONST(decltype(R2)), PO1.quantity_spec>
[[nodiscard]] constexpr QuantityPoint auto operator-(const quantity_point<R1, PO1, Rep1>& qp, [[nodiscard]] constexpr QuantityPoint auto operator-(const quantity_point<R1, PO1, Rep1>& qp,
const quantity<R2, Rep2>& q) const quantity<R2, Rep2>& q)
requires requires { qp.quantity_ref_from(PO1) - q; } requires requires { qp.quantity_ref_from(PO1) - q; }

View File

@@ -483,7 +483,7 @@ struct kind_of_<Q> : quantity_spec<kind_of_<Q>, Q{}> {
MP_UNITS_EXPORT template<detail::QuantitySpecWithNoSpecifiers auto Q> MP_UNITS_EXPORT template<detail::QuantitySpecWithNoSpecifiers auto Q>
requires(detail::get_kind_tree_root(Q) == Q) requires(detail::get_kind_tree_root(Q) == Q)
inline constexpr kind_of_<decltype(Q)> kind_of; inline constexpr kind_of_<MP_UNITS_REMOVE_CONST(decltype(Q))> kind_of;
namespace detail { namespace detail {
@@ -493,7 +493,7 @@ struct is_dimensionless<struct dimensionless> : std::true_type {};
template<QuantitySpec auto... From, QuantitySpec Q> template<QuantitySpec auto... From, QuantitySpec Q>
[[nodiscard]] consteval QuantitySpec auto clone_kind_of(Q q) [[nodiscard]] consteval QuantitySpec auto clone_kind_of(Q q)
{ {
if constexpr ((... && QuantityKindSpec<decltype(From)>)) if constexpr ((... && QuantityKindSpec<MP_UNITS_REMOVE_CONST(decltype(From))>))
return kind_of<Q{}>; return kind_of<Q{}>;
else else
return q; return q;

View File

@@ -38,7 +38,7 @@ namespace mp_units {
namespace detail { namespace detail {
template<QuantitySpec auto Q, Unit auto U> template<QuantitySpec auto Q, Unit auto U>
using reference_t = reference<decltype(Q), decltype(U)>; using reference_t = reference<MP_UNITS_REMOVE_CONST(decltype(Q)), MP_UNITS_REMOVE_CONST(decltype(U))>;
} }
@@ -258,13 +258,13 @@ MP_UNITS_EXPORT_END
namespace detail { namespace detail {
template<AssociatedUnit auto To, AssociatedUnit From> template<AssociatedUnit auto To, AssociatedUnit From>
[[nodiscard]] consteval decltype(To) clone_reference_with(From) [[nodiscard]] consteval MP_UNITS_REMOVE_CONST(decltype(To)) clone_reference_with(From)
{ {
return {}; return {};
} }
template<Unit auto To, QuantitySpec QS, Unit U> template<Unit auto To, QuantitySpec QS, Unit U>
[[nodiscard]] consteval reference<QS, decltype(To)> clone_reference_with(reference<QS, U>) [[nodiscard]] consteval reference<QS, MP_UNITS_REMOVE_CONST(decltype(To))> clone_reference_with(reference<QS, U>)
{ {
return {}; return {};
} }

View File

@@ -68,9 +68,9 @@ struct system_reference {
template<Unit U> template<Unit U>
requires(convertible(coherent_unit, U{})) requires(convertible(coherent_unit, U{}))
#if MP_UNITS_COMP_MSVC #if MP_UNITS_COMP_MSVC
[[nodiscard]] constexpr decltype(reference<decltype(Q), U>{}) operator[](U) const [[nodiscard]] constexpr decltype(reference<MP_UNITS_REMOVE_CONST(decltype(quantity_spec)), U>{}) operator[](U) const
#else #else
[[nodiscard]] constexpr reference<decltype(Q), U> operator[](U) const [[nodiscard]] constexpr reference<MP_UNITS_REMOVE_CONST(decltype(quantity_spec)), U> operator[](U) const
#endif #endif
{ {
return {}; return {};

View File

@@ -42,14 +42,14 @@ template<PrefixableUnit U> struct yobi_ : prefixed_unit<"Yi", mag_power<2, 80>,
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
template<PrefixableUnit auto U> inline constexpr kibi_<decltype(U)> kibi; template<PrefixableUnit auto U> inline constexpr kibi_<MP_UNITS_REMOVE_CONST(decltype(U))> kibi;
template<PrefixableUnit auto U> inline constexpr mebi_<decltype(U)> mebi; template<PrefixableUnit auto U> inline constexpr mebi_<MP_UNITS_REMOVE_CONST(decltype(U))> mebi;
template<PrefixableUnit auto U> inline constexpr gibi_<decltype(U)> gibi; template<PrefixableUnit auto U> inline constexpr gibi_<MP_UNITS_REMOVE_CONST(decltype(U))> gibi;
template<PrefixableUnit auto U> inline constexpr tebi_<decltype(U)> tebi; template<PrefixableUnit auto U> inline constexpr tebi_<MP_UNITS_REMOVE_CONST(decltype(U))> tebi;
template<PrefixableUnit auto U> inline constexpr pebi_<decltype(U)> pebi; template<PrefixableUnit auto U> inline constexpr pebi_<MP_UNITS_REMOVE_CONST(decltype(U))> pebi;
template<PrefixableUnit auto U> inline constexpr exbi_<decltype(U)> exbi; template<PrefixableUnit auto U> inline constexpr exbi_<MP_UNITS_REMOVE_CONST(decltype(U))> exbi;
template<PrefixableUnit auto U> inline constexpr zebi_<decltype(U)> zebi; template<PrefixableUnit auto U> inline constexpr zebi_<MP_UNITS_REMOVE_CONST(decltype(U))> zebi;
template<PrefixableUnit auto U> inline constexpr yobi_<decltype(U)> yobi; template<PrefixableUnit auto U> inline constexpr yobi_<MP_UNITS_REMOVE_CONST(decltype(U))> yobi;
// clang-format on // clang-format on
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

View File

@@ -58,30 +58,30 @@ template<PrefixableUnit U> struct quetta_ : prefixed_unit<"Q", mag_power<10, 30>
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
template<PrefixableUnit auto U> inline constexpr quecto_<decltype(U)> quecto; template<PrefixableUnit auto U> inline constexpr quecto_<MP_UNITS_REMOVE_CONST(decltype(U))> quecto;
template<PrefixableUnit auto U> inline constexpr ronto_<decltype(U)> ronto; template<PrefixableUnit auto U> inline constexpr ronto_<MP_UNITS_REMOVE_CONST(decltype(U))> ronto;
template<PrefixableUnit auto U> inline constexpr yocto_<decltype(U)> yocto; template<PrefixableUnit auto U> inline constexpr yocto_<MP_UNITS_REMOVE_CONST(decltype(U))> yocto;
template<PrefixableUnit auto U> inline constexpr zepto_<decltype(U)> zepto; template<PrefixableUnit auto U> inline constexpr zepto_<MP_UNITS_REMOVE_CONST(decltype(U))> zepto;
template<PrefixableUnit auto U> inline constexpr atto_<decltype(U)> atto; template<PrefixableUnit auto U> inline constexpr atto_<MP_UNITS_REMOVE_CONST(decltype(U))> atto;
template<PrefixableUnit auto U> inline constexpr femto_<decltype(U)> femto; template<PrefixableUnit auto U> inline constexpr femto_<MP_UNITS_REMOVE_CONST(decltype(U))> femto;
template<PrefixableUnit auto U> inline constexpr pico_<decltype(U)> pico; template<PrefixableUnit auto U> inline constexpr pico_<MP_UNITS_REMOVE_CONST(decltype(U))> pico;
template<PrefixableUnit auto U> inline constexpr nano_<decltype(U)> nano; template<PrefixableUnit auto U> inline constexpr nano_<MP_UNITS_REMOVE_CONST(decltype(U))> nano;
template<PrefixableUnit auto U> inline constexpr micro_<decltype(U)> micro; template<PrefixableUnit auto U> inline constexpr micro_<MP_UNITS_REMOVE_CONST(decltype(U))> micro;
template<PrefixableUnit auto U> inline constexpr milli_<decltype(U)> milli; template<PrefixableUnit auto U> inline constexpr milli_<MP_UNITS_REMOVE_CONST(decltype(U))> milli;
template<PrefixableUnit auto U> inline constexpr centi_<decltype(U)> centi; template<PrefixableUnit auto U> inline constexpr centi_<MP_UNITS_REMOVE_CONST(decltype(U))> centi;
template<PrefixableUnit auto U> inline constexpr deci_<decltype(U)> deci; template<PrefixableUnit auto U> inline constexpr deci_<MP_UNITS_REMOVE_CONST(decltype(U))> deci;
template<PrefixableUnit auto U> inline constexpr deca_<decltype(U)> deca; template<PrefixableUnit auto U> inline constexpr deca_<MP_UNITS_REMOVE_CONST(decltype(U))> deca;
template<PrefixableUnit auto U> inline constexpr hecto_<decltype(U)> hecto; template<PrefixableUnit auto U> inline constexpr hecto_<MP_UNITS_REMOVE_CONST(decltype(U))> hecto;
template<PrefixableUnit auto U> inline constexpr kilo_<decltype(U)> kilo; template<PrefixableUnit auto U> inline constexpr kilo_<MP_UNITS_REMOVE_CONST(decltype(U))> kilo;
template<PrefixableUnit auto U> inline constexpr mega_<decltype(U)> mega; template<PrefixableUnit auto U> inline constexpr mega_<MP_UNITS_REMOVE_CONST(decltype(U))> mega;
template<PrefixableUnit auto U> inline constexpr giga_<decltype(U)> giga; template<PrefixableUnit auto U> inline constexpr giga_<MP_UNITS_REMOVE_CONST(decltype(U))> giga;
template<PrefixableUnit auto U> inline constexpr tera_<decltype(U)> tera; template<PrefixableUnit auto U> inline constexpr tera_<MP_UNITS_REMOVE_CONST(decltype(U))> tera;
template<PrefixableUnit auto U> inline constexpr peta_<decltype(U)> peta; template<PrefixableUnit auto U> inline constexpr peta_<MP_UNITS_REMOVE_CONST(decltype(U))> peta;
template<PrefixableUnit auto U> inline constexpr exa_<decltype(U)> exa; template<PrefixableUnit auto U> inline constexpr exa_<MP_UNITS_REMOVE_CONST(decltype(U))> exa;
template<PrefixableUnit auto U> inline constexpr zetta_<decltype(U)> zetta; template<PrefixableUnit auto U> inline constexpr zetta_<MP_UNITS_REMOVE_CONST(decltype(U))> zetta;
template<PrefixableUnit auto U> inline constexpr yotta_<decltype(U)> yotta; template<PrefixableUnit auto U> inline constexpr yotta_<MP_UNITS_REMOVE_CONST(decltype(U))> yotta;
template<PrefixableUnit auto U> inline constexpr ronna_<decltype(U)> ronna; template<PrefixableUnit auto U> inline constexpr ronna_<MP_UNITS_REMOVE_CONST(decltype(U))> ronna;
template<PrefixableUnit auto U> inline constexpr quetta_<decltype(U)> quetta; template<PrefixableUnit auto U> inline constexpr quetta_<MP_UNITS_REMOVE_CONST(decltype(U))> quetta;
// clang-format on // clang-format on
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

View File

@@ -27,7 +27,7 @@
#include <type_traits> #include <type_traits>
template<auto V, typename T> template<auto V, typename T>
inline constexpr bool is_of_type = std::is_same_v<decltype(V), T>; inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
// NOLINTBEGIN(cppcoreguidelines-macro-usage) // NOLINTBEGIN(cppcoreguidelines-macro-usage)
#ifdef MP_UNITS_API_NO_CRTP #ifdef MP_UNITS_API_NO_CRTP