mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
refactor: 💥 is_XXX
customization points for representation types removed
This commit is contained in:
@@ -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>
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user