refactor: 💥 is_XXX customization points for representation types removed

This commit is contained in:
Mateusz Pusz
2024-11-26 14:48:08 +01:00
parent 083ef6adb1
commit 465f88d500
21 changed files with 151 additions and 205 deletions

View File

@ -43,12 +43,6 @@ import mp_units;
template<typename Rep = double>
using vector = STD_LA::fixed_size_column_vector<Rep, 3>;
template<class Rep>
constexpr bool mp_units::treat_as_floating_point<vector<Rep>> = mp_units::treat_as_floating_point<Rep>;
template<typename Rep>
constexpr bool mp_units::is_vector<vector<Rep>> = true;
template<typename Rep>
std::ostream& operator<<(std::ostream& os, const vector<Rep>& v)
{
@ -87,8 +81,6 @@ template<typename T, typename U>
}
template<Quantity Q1, Quantity Q2>
requires is_vector<typename Q1::rep> && is_vector<typename Q2::rep> &&
requires(typename Q1::rep v1, typename Q2::rep v2) { cross_product(v1, v2); }
[[nodiscard]] constexpr QuantityOf<Q1::quantity_spec * Q2::quantity_spec> auto cross_product(const Q1& q1, const Q2& q2)
{
return cross_product(q1.numerical_value_ref_in(q1.unit), q2.numerical_value_ref_in(q2.unit)) *
@ -299,10 +291,6 @@ TEST_CASE("vector quantity", "[la]")
}
}
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
TEST_CASE("vector of quantities", "[la]")
{
SECTION("cast of unit")

View File

@ -278,13 +278,16 @@ static_assert(!Representation<std::chrono::seconds>);
// RepresentationOf
static_assert(RepresentationOf<int, quantity_character::scalar>);
static_assert(!RepresentationOf<int, quantity_character::complex>);
static_assert(!RepresentationOf<int, quantity_character::vector>);
static_assert(RepresentationOf<int, quantity_character::vector>);
static_assert(!RepresentationOf<int, quantity_character::tensor>);
static_assert(RepresentationOf<double, quantity_character::scalar>);
static_assert(!RepresentationOf<double, quantity_character::complex>);
static_assert(!RepresentationOf<double, quantity_character::vector>);
static_assert(RepresentationOf<double, quantity_character::vector>);
static_assert(!RepresentationOf<double, quantity_character::tensor>);
static_assert(!RepresentationOf<bool, quantity_character::scalar>);
static_assert(!RepresentationOf<bool, quantity_character::complex>);
static_assert(!RepresentationOf<bool, quantity_character::vector>);
static_assert(!RepresentationOf<bool, quantity_character::tensor>);
static_assert(!RepresentationOf<std::optional<int>, quantity_character::scalar>);
#if MP_UNITS_HOSTED
static_assert(RepresentationOf<std::complex<double>, quantity_character::complex>);

View File

@ -60,9 +60,6 @@ public:
} // namespace
template<typename T>
constexpr bool mp_units::is_scalar<min_impl<T>> = true;
template<typename T, typename U>
struct std::common_type<min_impl<T>, min_impl<U>> : std::type_identity<min_impl<std::common_type_t<T, U>>> {};
template<typename T, typename U>

View File

@ -24,10 +24,6 @@
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/si.h>
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
namespace {
using namespace mp_units;

View File

@ -26,10 +26,6 @@
#include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/units.h>
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
namespace {
using namespace mp_units;

View File

@ -22,10 +22,6 @@
#include <mp-units/systems/natural.h>
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
namespace {
using namespace mp_units;

View File

@ -47,9 +47,6 @@ import std;
#endif
#endif
template<>
constexpr bool mp_units::is_vector<int> = true;
namespace {
using namespace mp_units;
@ -74,8 +71,10 @@ concept invalid_types = requires {
requires !requires { typename Q<isq::length, double>; }; // quantity_spec instead of reference
requires !requires { typename Q<isq::length[m], bool>; }; // bool is not a valid representation type
requires !requires { typename Q<isq::length[m], quantity<isq::length[m]>>; }; // quantity used as Rep
requires !requires { typename Q<isq::position_vector[si::metre], double>; }; // vector representation expected
#if MP_UNITS_HOSTED
requires !requires {
typename Q<isq::position_vector[si::metre], std::complex<double>>;
}; // vector representation expected
requires !requires {
typename Q<isq::length[si::metre], cartesian_vector<double>>;
}; // scalar representation expected