diff --git a/src/core/include/mp-units/bits/external/hacks.h b/src/core/include/mp-units/bits/external/hacks.h index 34479a34..4bd4d0a4 100644 --- a/src/core/include/mp-units/bits/external/hacks.h +++ b/src/core/include/mp-units/bits/external/hacks.h @@ -107,7 +107,7 @@ #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 diff --git a/src/core/include/mp-units/bits/reference_concepts.h b/src/core/include/mp-units/bits/reference_concepts.h index e0e3d6a4..849d0427 100644 --- a/src/core/include/mp-units/bits/reference_concepts.h +++ b/src/core/include/mp-units/bits/reference_concepts.h @@ -32,11 +32,12 @@ struct reference; namespace detail { +// do not refactor below to a variable template - GCC-11 does not like it template -inline constexpr bool is_specialization_of_reference = false; +struct is_specialization_of_reference : std::false_type {}; template -inline constexpr bool is_specialization_of_reference> = true; +struct is_specialization_of_reference> : std::true_type {}; } // namespace detail @@ -46,7 +47,7 @@ inline constexpr bool is_specialization_of_reference> = true; * Satisfied by all specializations of @c reference. */ template -concept Reference = AssociatedUnit || detail::is_specialization_of_reference; +concept Reference = AssociatedUnit || detail::is_specialization_of_reference::value; [[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u); diff --git a/src/core/include/mp-units/bits/unit_concepts.h b/src/core/include/mp-units/bits/unit_concepts.h index ba727a20..7fcdec2a 100644 --- a/src/core/include/mp-units/bits/unit_concepts.h +++ b/src/core/include/mp-units/bits/unit_concepts.h @@ -31,8 +31,9 @@ namespace mp_units { namespace detail { +// do not refactor below to a variable template - GCC-11 does not like it template -inline constexpr bool is_unit = false; +struct is_unit : std::false_type {}; } // namespace detail @@ -42,7 +43,7 @@ inline constexpr bool is_unit = false; * Satisfied by all unit types provided by the library. */ template -concept Unit = detail::is_unit; +concept Unit = detail::is_unit::value; template struct scaled_unit; @@ -140,8 +141,8 @@ template inline constexpr bool is_specialization_of_prefixed_unit> = true; template - requires requires(T* t) { is_unit_impl(t); } -inline constexpr bool is_unit = !is_specialization_of_named_unit && !is_specialization_of_prefixed_unit; + requires requires(T* t) { is_unit_impl(t); } && (!is_specialization_of_named_unit) && (!is_specialization_of_prefixed_unit) +struct is_unit : std::true_type {}; template [[nodiscard]] consteval bool has_associated_quantity(U); diff --git a/src/core/include/mp-units/bits/value_cast.h b/src/core/include/mp-units/bits/value_cast.h index 27c6d268..3fcf5745 100644 --- a/src/core/include/mp-units/bits/value_cast.h +++ b/src/core/include/mp-units/bits/value_cast.h @@ -46,7 +46,7 @@ template { using q_type = std::remove_reference_t; constexpr auto r = [] { - if constexpr (detail::is_specialization_of_reference> || + if constexpr (detail::is_specialization_of_reference>::value || !AssociatedUnit>) return reference{}; else diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index c94d1af3..ad381cc1 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -115,7 +115,7 @@ struct quantity_spec_interface { } #else template U> - [[nodiscard]] consteval Reference auto operator[](U u) const + [[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const { if constexpr (detail::QuantityKindSpec) return u; @@ -294,7 +294,7 @@ struct quantity_spec : std::remove_const_t { #ifndef __cpp_explicit_this_parameter template U> - [[nodiscard]] consteval Reference auto operator[](U u) const + [[nodiscard]] MP_UNITS_CONSTEVAL Reference auto operator[](U u) const { if constexpr (detail::QuantityKindSpec) return u; diff --git a/test/unit_test/static/unit_symbol_test.cpp b/test/unit_test/static/unit_symbol_test.cpp index f1130610..a642caaf 100644 --- a/test/unit_test/static/unit_symbol_test.cpp +++ b/test/unit_test/static/unit_symbol_test.cpp @@ -30,7 +30,7 @@ using namespace mp_units; using namespace mp_units::si; 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 unit_symbol_solidus;