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

@@ -62,9 +62,6 @@ public:
}
};
template<typename T, auto Min, auto Max>
constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>;
template<typename T, auto Min, auto Max, typename Char>
struct MP_UNITS_STD_FMT::formatter<ranged_representation<T, Min, Max>, Char> : formatter<T, Char> {
template<typename FormatContext>

View File

@@ -113,9 +113,6 @@ public:
= default;
};
template<typename T, typename Validator>
constexpr bool mp_units::is_scalar<validated_type<T, Validator>> = mp_units::is_scalar<T>;
template<typename CharT, typename Traits, typename T, typename Validator>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os,

View File

@@ -38,10 +38,6 @@ import mp_units;
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex2
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units;
void print_header(const kalman::SystemState auto& initial)

View File

@@ -38,10 +38,6 @@ import mp_units;
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex3
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units;
void print_header(const kalman::SystemState auto& initial)

View File

@@ -38,10 +38,6 @@ import mp_units;
// Based on: https://www.kalmanfilter.net/alphabeta.html#ex4
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units;
void print_header(const kalman::SystemState auto& initial)

View File

@@ -124,6 +124,13 @@ public:
return os << v.value() << " ± " << v.uncertainty();
}
[[nodiscard]] friend constexpr measurement abs(const measurement& v)
requires requires { abs(v.value()); } || requires { std::abs(v.value()); }
{
using std::abs;
return measurement(abs(v.value()), v.uncertainty());
}
private:
value_type value_{};
value_type uncertainty_{};
@@ -131,12 +138,8 @@ private:
} // namespace
template<typename T>
constexpr bool mp_units::is_scalar<measurement<T>> = true;
template<typename T>
constexpr bool mp_units::is_vector<measurement<T>> = true;
static_assert(mp_units::RepresentationOf<measurement<double>, mp_units::quantity_character::scalar>);
static_assert(mp_units::RepresentationOf<measurement<double>, mp_units::quantity_character::vector>);
namespace {

View File

@@ -40,12 +40,6 @@ import mp_units;
#include <mp-units/systems/si.h>
#endif
// allows standard gravity (acceleration) and weight (force) to be expressed with scalar representation
// types instead of requiring the usage of Linear Algebra library for this simple example
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
namespace {
using namespace mp_units;

View File

@@ -33,10 +33,6 @@ import mp_units;
#include <mp-units/systems/si.h>
#endif
template<class T>
requires mp_units::is_scalar<T>
constexpr bool mp_units::is_vector<T> = true;
int main()
{
using namespace mp_units;

View File

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