mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 04:14:27 +02:00
refactor: workarounds to make gcc-11 compile
This commit is contained in:
@@ -107,7 +107,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MP_UNITS_COMP_CLANG < 17
|
#if (defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 17) || (defined MP_UNITS_COMP_GCC && MP_UNITS_COMP_GCC < 12)
|
||||||
|
|
||||||
#define MP_UNITS_CONSTEVAL constexpr
|
#define MP_UNITS_CONSTEVAL constexpr
|
||||||
|
|
||||||
|
@@ -32,11 +32,12 @@ struct reference;
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
// do not refactor below to a variable template - GCC-11 does not like it
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline constexpr bool is_specialization_of_reference = false;
|
struct is_specialization_of_reference : std::false_type {};
|
||||||
|
|
||||||
template<auto Q, auto U>
|
template<auto Q, auto U>
|
||||||
inline constexpr bool is_specialization_of_reference<reference<Q, U>> = true;
|
struct is_specialization_of_reference<reference<Q, U>> : std::true_type {};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ inline constexpr bool is_specialization_of_reference<reference<Q, U>> = true;
|
|||||||
* Satisfied by all specializations of @c reference.
|
* Satisfied by all specializations of @c reference.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Reference = AssociatedUnit<T> || detail::is_specialization_of_reference<T>;
|
concept Reference = AssociatedUnit<T> || detail::is_specialization_of_reference<T>::value;
|
||||||
|
|
||||||
[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u);
|
[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u);
|
||||||
|
|
||||||
|
@@ -31,8 +31,9 @@ namespace mp_units {
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
// do not refactor below to a variable template - GCC-11 does not like it
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline constexpr bool is_unit = false;
|
struct is_unit : std::false_type {};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ inline constexpr bool is_unit = false;
|
|||||||
* Satisfied by all unit types provided by the library.
|
* Satisfied by all unit types provided by the library.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Unit = detail::is_unit<T>;
|
concept Unit = detail::is_unit<T>::value;
|
||||||
|
|
||||||
template<Magnitude auto M, Unit U>
|
template<Magnitude auto M, Unit U>
|
||||||
struct scaled_unit;
|
struct scaled_unit;
|
||||||
@@ -140,8 +141,8 @@ template<basic_symbol_text Symbol, Magnitude auto M, PrefixableUnit auto U>
|
|||||||
inline constexpr bool is_specialization_of_prefixed_unit<prefixed_unit<Symbol, M, U>> = true;
|
inline constexpr bool is_specialization_of_prefixed_unit<prefixed_unit<Symbol, M, U>> = true;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
requires requires(T* t) { is_unit_impl(t); }
|
requires requires(T* t) { is_unit_impl(t); } && (!is_specialization_of_named_unit<T>) && (!is_specialization_of_prefixed_unit<T>)
|
||||||
inline constexpr bool is_unit<T> = !is_specialization_of_named_unit<T> && !is_specialization_of_prefixed_unit<T>;
|
struct is_unit<T> : std::true_type {};
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
[[nodiscard]] consteval bool has_associated_quantity(U);
|
[[nodiscard]] consteval bool has_associated_quantity(U);
|
||||||
|
@@ -46,7 +46,7 @@ template<Unit auto ToU, typename Q>
|
|||||||
{
|
{
|
||||||
using q_type = std::remove_reference_t<Q>;
|
using q_type = std::remove_reference_t<Q>;
|
||||||
constexpr auto r = [] {
|
constexpr auto r = [] {
|
||||||
if constexpr (detail::is_specialization_of_reference<std::remove_const_t<decltype(q_type::reference)>> ||
|
if constexpr (detail::is_specialization_of_reference<std::remove_const_t<decltype(q_type::reference)>>::value ||
|
||||||
!AssociatedUnit<std::remove_const_t<decltype(ToU)>>)
|
!AssociatedUnit<std::remove_const_t<decltype(ToU)>>)
|
||||||
return reference<q_type::quantity_spec, ToU>{};
|
return reference<q_type::quantity_spec, ToU>{};
|
||||||
else
|
else
|
||||||
|
@@ -115,7 +115,7 @@ struct quantity_spec_interface {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](U u) const
|
[[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const
|
||||||
{
|
{
|
||||||
if constexpr (detail::QuantityKindSpec<Self_>)
|
if constexpr (detail::QuantityKindSpec<Self_>)
|
||||||
return u;
|
return u;
|
||||||
@@ -294,7 +294,7 @@ struct quantity_spec<Self, QS, Args...> : std::remove_const_t<decltype(QS)> {
|
|||||||
|
|
||||||
#ifndef __cpp_explicit_this_parameter
|
#ifndef __cpp_explicit_this_parameter
|
||||||
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
template<typename Self_ = Self, UnitOf<Self_{}> U>
|
||||||
[[nodiscard]] consteval Reference auto operator[](U u) const
|
[[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const
|
||||||
{
|
{
|
||||||
if constexpr (detail::QuantityKindSpec<Self>)
|
if constexpr (detail::QuantityKindSpec<Self>)
|
||||||
return u;
|
return u;
|
||||||
|
@@ -30,7 +30,7 @@ using namespace mp_units;
|
|||||||
using namespace mp_units::si;
|
using namespace mp_units::si;
|
||||||
using namespace mp_units::iec80000;
|
using namespace mp_units::iec80000;
|
||||||
|
|
||||||
#ifdef __cpp_lib_constexpr_string
|
#if __cpp_lib_constexpr_string && (!defined MP_UNITS_COMP_GCC || MP_UNITS_COMP_GCC > 11)
|
||||||
|
|
||||||
using enum text_encoding;
|
using enum text_encoding;
|
||||||
using enum unit_symbol_solidus;
|
using enum unit_symbol_solidus;
|
||||||
|
Reference in New Issue
Block a user