Skip to content

Commit

Permalink
Merge branch 'master' into feature/update-apple-clang-test-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
rothmichaels authored Dec 19, 2024
2 parents ad3beef + 75ae652 commit e5f9626
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
4 changes: 4 additions & 0 deletions src/core/include/mp-units/bits/hacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,9 @@ MP_UNITS_DIAGNOSTIC_POP

#define MP_UNITS_API_NO_CRTP 1

#endif

#if defined(__clang__) && defined(__apple_build_version__) && __apple_build_version__ < 16000026
#define MP_UNITS_XCODE15_HACKS
#endif
// NOLINTEND(bugprone-reserved-identifier, cppcoreguidelines-macro-usage)
63 changes: 36 additions & 27 deletions src/core/include/mp-units/framework/representation_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ concept Scalar = (!disable_scalar<T>) &&
{ a + b } -> std::common_with<T>;
{ a - b } -> std::common_with<T>;
} && ScalableWith<T, T>
#if MP_UNITS_COMP_GCC != 12
#if MP_UNITS_COMP_GCC != 12 && !defined(MP_UNITS_XCODE15_HACKS)
&& WeaklyRegular<T>
#endif
;
Expand Down Expand Up @@ -177,19 +177,23 @@ constexpr bool disable_complex = false;
namespace detail {

template<typename T>
concept Complex = (!disable_complex<T>) && requires(const T a, const T b, const T& c) {
{ -a } -> std::common_with<T>;
{ a + b } -> std::common_with<T>;
{ a - b } -> std::common_with<T>;
{ a* b } -> std::common_with<T>;
{ a / b } -> std::common_with<T>;
::mp_units::real(a);
::mp_units::imag(a);
::mp_units::modulus(a);
requires ScalableWith<T, decltype(::mp_units::modulus(a))>;
requires std::constructible_from<T, decltype(::mp_units::real(c)), decltype(::mp_units::imag(c))>;
} && WeaklyRegular<T>;

concept Complex = (!disable_complex<T>) &&
requires(const T a, const T b, const T& c) {
{ -a } -> std::common_with<T>;
{ a + b } -> std::common_with<T>;
{ a - b } -> std::common_with<T>;
{ a* b } -> std::common_with<T>;
{ a / b } -> std::common_with<T>;
::mp_units::real(a);
::mp_units::imag(a);
::mp_units::modulus(a);
requires ScalableWith<T, decltype(::mp_units::modulus(a))>;
requires std::constructible_from<T, decltype(::mp_units::real(c)), decltype(::mp_units::imag(c))>;
}
#ifndef MP_UNITS_XCODE15_HACKS
&& WeaklyRegular<T>
#endif
;
namespace magnitude_impl {

void magnitude() = delete; // poison pill
Expand Down Expand Up @@ -238,19 +242,24 @@ constexpr bool disable_vector = false;
namespace detail {

template<typename T>
concept Vector = (!disable_vector<T>) && requires(const T a, const T b) {
{ -a } -> std::common_with<T>;
{ a + b } -> std::common_with<T>;
{ a - b } -> std::common_with<T>;
::mp_units::magnitude(a);
requires ScalableWith<T, decltype(::mp_units::magnitude(a))>;
// TODO should we also check for the below (e.g., when `size() > 1` or `2`)
// ::mp_units::zero_vector<T>();
// ::mp_units::unit_vector(a);
// ::mp_units::scalar_product(a, b);
// ::mp_units::vector_product(a, b);
// ::mp_units::tensor_product(a, b);
} && WeaklyRegular<T>;
concept Vector = (!disable_vector<T>) &&
requires(const T a, const T b) {
{ -a } -> std::common_with<T>;
{ a + b } -> std::common_with<T>;
{ a - b } -> std::common_with<T>;
::mp_units::magnitude(a);
requires ScalableWith<T, decltype(::mp_units::magnitude(a))>;
// TODO should we also check for the below (e.g., when `size() > 1` or `2`)
// ::mp_units::zero_vector<T>();
// ::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<T>
#endif
;

} // namespace detail

Expand Down

0 comments on commit e5f9626

Please sign in to comment.