diff --git a/src/core/include/mp-units/bits/hacks.h b/src/core/include/mp-units/bits/hacks.h index f27c5438..f9e98f24 100644 --- a/src/core/include/mp-units/bits/hacks.h +++ b/src/core/include/mp-units/bits/hacks.h @@ -153,6 +153,6 @@ MP_UNITS_DIAGNOSTIC_POP #endif #if defined(__clang__) && defined(__apple_build_version__) && __apple_build_version__ < 16000026 -#define MP_UNITS_APPLE_CLANG_HACKS +#define MP_UNITS_XCODE15_HACKS #endif // NOLINTEND(bugprone-reserved-identifier, cppcoreguidelines-macro-usage) diff --git a/src/core/include/mp-units/framework/representation_concepts.h b/src/core/include/mp-units/framework/representation_concepts.h index d556be51..37e5354a 100644 --- a/src/core/include/mp-units/framework/representation_concepts.h +++ b/src/core/include/mp-units/framework/representation_concepts.h @@ -88,7 +88,7 @@ concept Scalar = (!disable_scalar) && { a + b } -> std::common_with; { a - b } -> std::common_with; } && ScalableWith -#if MP_UNITS_COMP_GCC != 12 +#if MP_UNITS_COMP_GCC != 12 && !defined(MP_UNITS_XCODE15_HACKS) && WeaklyRegular #endif ; @@ -177,18 +177,23 @@ constexpr bool disable_complex = false; namespace detail { template -concept Complex = (!disable_complex) && requires(const T a, const T b, const T& c) { - { -a } -> std::common_with; - { a + b } -> std::common_with; - { a - b } -> std::common_with; - { a* b } -> std::common_with; - { a / b } -> std::common_with; - ::mp_units::real(a); - ::mp_units::imag(a); - ::mp_units::modulus(a); - requires ScalableWith; - requires std::constructible_from; -} && WeaklyRegular; +concept Complex = (!disable_complex) && + requires(const T a, const T b, const T& c) { + { -a } -> std::common_with; + { a + b } -> std::common_with; + { a - b } -> std::common_with; + { a* b } -> std::common_with; + { a / b } -> std::common_with; + ::mp_units::real(a); + ::mp_units::imag(a); + ::mp_units::modulus(a); + requires ScalableWith; + requires std::constructible_from; + } +#ifndef MP_UNITS_XCODE15_HACKS + && WeaklyRegular +#endif + ; namespace magnitude_impl { @@ -238,19 +243,24 @@ constexpr bool disable_vector = false; namespace detail { template -concept Vector = (!disable_vector) && requires(const T a, const T b) { - { -a } -> std::common_with; - { a + b } -> std::common_with; - { a - b } -> std::common_with; - ::mp_units::magnitude(a); - requires ScalableWith; - // TODO should we also check for the below (e.g., when `size() > 1` or `2`) - // ::mp_units::zero_vector(); - // ::mp_units::unit_vector(a); - // ::mp_units::scalar_product(a, b); - // ::mp_units::vector_product(a, b); - // ::mp_units::tensor_product(a, b); -} && WeaklyRegular; +concept Vector = (!disable_vector) && + requires(const T a, const T b) { + { -a } -> std::common_with; + { a + b } -> std::common_with; + { a - b } -> std::common_with; + ::mp_units::magnitude(a); + requires ScalableWith; + // TODO should we also check for the below (e.g., when `size() > 1` or `2`) + // ::mp_units::zero_vector(); + // ::mp_units::unit_vector(a); + // ::mp_units::scalar_product(a, b); + // ::mp_units::vector_product(a, b); + // ::mp_units::tensor_product(a, b); + } +#ifndef MP_UNITS_XCODE15_HACKS + && WeaklyRegular +#endif + ; } // namespace detail @@ -313,42 +323,12 @@ concept Representation = detail::ScalarRepresentation || detail::ComplexRepre namespace detail { -#ifdef MP_UNITS_APPLE_CLANG_HACKS -template -constexpr bool is_weakly_regular = std::copyable && std::equality_comparable; - -template -constexpr bool is_scalar = !disable_scalar && is_weakly_regular; - -template -constexpr bool is_complex = !disable_complex && is_weakly_regular && is_scalar> && - std::constructible_from, value_type_t>; - -template -concept ComplexFunctionsAvailable = requires(T a) { - ::mp_units::real(a); - ::mp_units::imag(a); - ::mp_units::modulus(a); -}; - -template -constexpr bool is_vector = !disable_vector && is_weakly_regular && is_scalar>; - -template -concept VectorFunctionsAvailable = requires(T a) { ::mp_units::magnitude(a); }; - - -template -concept IsOfCharacter = ((Ch == quantity_character::scalar && is_scalar) || - (Ch == quantity_character::complex && is_complex && ComplexFunctionsAvailable) || - (Ch == quantity_character::vector && is_vector && VectorFunctionsAvailable)); -#else template concept IsOfCharacter = (Ch == quantity_character::scalar && Scalar) || (Ch == quantity_character::complex && Complex) || (Ch == quantity_character::vector && Vector); // || (Ch == quantity_character::tensor && Tensor); -#endif -} // namespace detail + +} MP_UNITS_EXPORT template concept RepresentationOf = diff --git a/test/static/concepts_test.cpp b/test/static/concepts_test.cpp index 2cf15448..0b1a7bab 100644 --- a/test/static/concepts_test.cpp +++ b/test/static/concepts_test.cpp @@ -20,7 +20,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include #include #include @@ -309,9 +308,7 @@ static_assert(!RepresentationOf, quantity_character::scalar static_assert(!RepresentationOf, quantity_character::vector>); static_assert(!RepresentationOf, quantity_character::tensor>); static_assert(RepresentationOf, quantity_character::vector>); -#ifndef MP_UNITS_APPLE_CLANG_HACKS static_assert(!RepresentationOf, quantity_character::scalar>); -#endif static_assert(!RepresentationOf, quantity_character::complex>); static_assert(!RepresentationOf, quantity_character::tensor>); static_assert(!RepresentationOf); diff --git a/test/static/quantity_test.cpp b/test/static/quantity_test.cpp index 418c66a9..3b8d14d5 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -65,8 +65,6 @@ static_assert(sizeof(quantity) == sizeof(double)); static_assert(sizeof(quantity) == sizeof(short)); static_assert(sizeof(quantity) == sizeof(short)); -#ifndef MP_UNITS_APPLE_CLANG_HACKS - template typename Q> concept invalid_types = requires { requires !requires { typename Q; }; // dimension instead of reference @@ -86,8 +84,6 @@ concept invalid_types = requires { }; static_assert(invalid_types); -#endif - static_assert(std::is_trivially_default_constructible_v>); static_assert(std::is_trivially_copy_constructible_v>); static_assert(std::is_trivially_move_constructible_v>);