Fixes for apple-clang crashes and performance issues

The source of the crash with the latest changes seemed to be from the
`IsOfCharacter` concept.  This concept was refactored to use some type
traits and more simple concepts although with less strict requirements.

A new macro, `MP_UNITS_APPLE_CLANG_HACKS` was added to
mp-units/bits/hacks.h to enable work arounds for pre-Xcode 16.1 apple-clang.

Some tests were not passing and were removed with the preprocessor macro
for apple-clang hacks is defined.

Adding `ComplexFunctionsAvailable` and `VectorFunctionsAvailable` fixed
some test failures in concepts_test.cpp but not all.
This commit is contained in:
Roth Michaels
2024-12-09 17:39:21 +01:00
parent 6d93f7385a
commit c3e45088a6
4 changed files with 45 additions and 3 deletions
+5 -1
View File
@@ -65,6 +65,8 @@ static_assert(sizeof(quantity<isq::length[m]>) == sizeof(double));
static_assert(sizeof(quantity<si::metre, short>) == sizeof(short));
static_assert(sizeof(quantity<isq::length[m], short>) == sizeof(short));
#ifndef MP_UNITS_APPLE_CLANG_HACKS
template<template<auto, typename> typename Q>
concept invalid_types = requires {
requires !requires { typename Q<isq::dim_length, double>; }; // dimension instead of reference
@@ -77,13 +79,15 @@ concept invalid_types = requires {
}; // vector representation expected
requires !requires {
typename Q<isq::length[si::metre], cartesian_vector<double>>;
}; // scalar representation expected
}; // scalar representation expected
requires !requires { typename Q<isq::voltage[V], std::complex<double>>; }; // incompatible character
requires !requires { typename Q<isq::voltage_phasor[V], double>; }; // incompatible character
#endif
};
static_assert(invalid_types<quantity>);
#endif
static_assert(std::is_trivially_default_constructible_v<quantity<isq::length[m]>>);
static_assert(std::is_trivially_copy_constructible_v<quantity<isq::length[m]>>);
static_assert(std::is_trivially_move_constructible_v<quantity<isq::length[m]>>);