refactor: 💥 basic_concepts, quantity and quantity_cast refactored

BREAKING CHANGE:  ScalableNumber renamed to QuantityValue

Resolves #107
This commit is contained in:
Mateusz Pusz
2020-10-06 18:17:52 +02:00
parent 40f205b381
commit cfc90f4aac
96 changed files with 1620 additions and 1017 deletions
+3 -3
View File
@@ -33,7 +33,7 @@ struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio(3), foot> {};
struct dim_length : base_dimension<"L", foot> {};
template<Unit U, ScalableNumber Rep = double>
template<UnitOf<dim_length> U, QuantityValue Rep = double>
using length = quantity<dim_length, U, Rep>;
} // namespace fps
@@ -45,7 +45,7 @@ struct kilometre : prefixed_unit<kilometre, units::physical::si::kilo, metre> {}
struct dim_length : base_dimension<"L", metre> {};
template<Unit U, ScalableNumber Rep = double>
template<UnitOf<dim_length> U, QuantityValue Rep = double>
using length = quantity<dim_length, U, Rep>;
namespace fps {
@@ -55,7 +55,7 @@ struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio(3), foot> {};
struct dim_length : base_dimension<"L", foot> {};
template<Unit U, ScalableNumber Rep = double>
template<UnitOf<dim_length> U, QuantityValue Rep = double>
using length = quantity<dim_length, U, Rep>;
} // namespace fps
+2 -2
View File
@@ -87,7 +87,7 @@ public:
}
template<typename V>
requires (ScalableNumber<V> || Dimensionless<V>)
requires (QuantityValue<V> || Dimensionless<V>)
[[nodiscard]] friend constexpr auto operator*(const vector& lhs, const V& value)
requires requires { lhs.magnitude() * value; }
{
@@ -95,7 +95,7 @@ public:
}
template<typename V>
requires (ScalableNumber<V> || Dimensionless<V>)
requires (QuantityValue<V> || Dimensionless<V>)
[[nodiscard]] friend constexpr auto operator*(const V& value, const vector& rhs)
requires requires { value * rhs.magnitude(); }
{
+3 -3
View File
@@ -200,10 +200,10 @@ void matrix_of_quantity_tests()
matrix_of_quantity_divide_by_scalar();
}
template<units::Unit U = si::metre, units::ScalableNumber Rep = double>
template<units::Unit U = si::metre, units::QuantityValue Rep = double>
using length_v = si::length<U, vector<Rep>>;
template<units::Unit U = si::newton, units::ScalableNumber Rep = double>
template<units::Unit U = si::newton, units::QuantityValue Rep = double>
using force_v = si::force<U, vector<Rep>>;
void quantity_of_vector_add()
@@ -273,7 +273,7 @@ void quantity_of_vector_tests()
quantity_of_vector_divide_by_scalar();
}
template<units::Unit U = si::metre, units::ScalableNumber Rep = double>
template<units::Unit U = si::metre, units::QuantityValue Rep = double>
using length_m = si::length<U, matrix<Rep>>;
void quantity_of_matrix_add()
+2 -4
View File
@@ -114,15 +114,13 @@ private:
value_type uncertainty_{};
};
static_assert(units::ScalableNumber<measurement<double>>);
} // namespace
template<typename T>
inline constexpr bool units::treat_as_floating_point<measurement<T>> = std::is_floating_point_v<T>;
namespace {
static_assert(units::QuantityValue<measurement<double>>);
void example()
{
using namespace units::physical;