refactor: 💥 ! PrefixFamily support removed
It doesn't have much sense to restrict prefixes usage for most units and in many places we were wrong to do so already.
This commit is contained in:
1 parent
725d193122
commit
32b36fb670
66 files changed
+221
-268
No files matched your search
@@ -42,15 +42,9 @@ namespace {
|
||||
using namespace units;
|
||||
using namespace units::isq;
|
||||
|
||||
// Prefix family
|
||||
|
||||
static_assert(PrefixFamily<si::prefix>);
|
||||
static_assert(!PrefixFamily<si::kilo>);
|
||||
|
||||
// Prefix
|
||||
|
||||
static_assert(Prefix<si::kilo>);
|
||||
static_assert(!Prefix<si::prefix>);
|
||||
static_assert(!Prefix<std::kilo>);
|
||||
|
||||
// UnitRatio
|
||||
@@ -92,6 +86,13 @@ static_assert(!Unit<si::dim_length>);
|
||||
static_assert(!Unit<int>);
|
||||
static_assert(!Unit<std::chrono::seconds>);
|
||||
|
||||
// NamedUnit
|
||||
|
||||
static_assert(NamedUnit<si::metre>);
|
||||
static_assert(NamedUnit<si::kilometre>);
|
||||
static_assert(NamedUnit<si::fps::mile>);
|
||||
static_assert(!NamedUnit<si::metre_per_second>);
|
||||
|
||||
// UnitOf
|
||||
|
||||
static_assert(UnitOf<si::metre, si::dim_length>);
|
||||
|
||||
@@ -30,13 +30,13 @@ using namespace units;
|
||||
|
||||
namespace {
|
||||
|
||||
struct u0 : named_unit<u0, "u0", no_prefix> {};
|
||||
struct u0 : named_unit<u0, "u0"> {};
|
||||
struct d0 : base_dimension<"d0", u0> {};
|
||||
struct u1 : named_unit<u1, "u1", no_prefix> {};
|
||||
struct u1 : named_unit<u1, "u1"> {};
|
||||
struct d1 : base_dimension<"d1", u1> {};
|
||||
struct u2 : named_unit<u2, "u2", no_prefix> {};
|
||||
struct u2 : named_unit<u2, "u2"> {};
|
||||
struct d2 : base_dimension<"d2", u2> {};
|
||||
struct u3 : named_unit<u3, "u3", no_prefix> {};
|
||||
struct u3 : named_unit<u3, "u3"> {};
|
||||
struct d3 : base_dimension<"d3", u3> {};
|
||||
|
||||
// exponent_invert
|
||||
|
||||
@@ -94,9 +94,9 @@ static_assert(
|
||||
is_same_v<type_list_split_half<type_list<int, long, double, float>>::second_list, type_list<double, float>>);
|
||||
|
||||
// type_list_merge_sorted
|
||||
struct u0 : named_unit<u0, "u0", no_prefix> {};
|
||||
struct u0 : named_unit<u0, "u0"> {};
|
||||
struct d0 : base_dimension<"d0", u0> {};
|
||||
struct u1 : named_unit<u1, "u1", no_prefix> {};
|
||||
struct u1 : named_unit<u1, "u1"> {};
|
||||
struct d1 : base_dimension<"d1", u1> {};
|
||||
|
||||
static_assert(
|
||||
|
||||
@@ -33,22 +33,22 @@ namespace {
|
||||
using namespace units;
|
||||
using namespace units::isq;
|
||||
|
||||
struct metre : named_unit<metre, "m", si::prefix> {};
|
||||
struct metre : named_unit<metre, "m"> {};
|
||||
struct centimetre : prefixed_unit<centimetre, si::centi, metre> {};
|
||||
struct kilometre : prefixed_unit<kilometre, si::kilo, metre> {};
|
||||
struct yard : named_scaled_unit<yard, "yd", no_prefix, ratio(9'144, 1, -4), metre> {};
|
||||
struct foot : named_scaled_unit<foot, "ft", no_prefix, ratio(1, 3), yard> {};
|
||||
struct yard : named_scaled_unit<yard, "yd", ratio(9'144, 1, -4), metre> {};
|
||||
struct foot : named_scaled_unit<foot, "ft", ratio(1, 3), yard> {};
|
||||
struct dim_length : base_dimension<"length", metre> {};
|
||||
|
||||
struct second : named_unit<second, "s", si::prefix> {};
|
||||
struct hour : named_scaled_unit<hour, "h", no_prefix, ratio(36, 1, 2), second> {};
|
||||
struct second : named_unit<second, "s"> {};
|
||||
struct hour : named_scaled_unit<hour, "h", ratio(36, 1, 2), second> {};
|
||||
struct dim_time : base_dimension<"time", second> {};
|
||||
|
||||
struct kelvin : named_unit<kelvin, "K", no_prefix> {};
|
||||
struct kelvin : named_unit<kelvin, "K"> {};
|
||||
|
||||
#if !UNITS_COMP_MSVC
|
||||
static_assert([]<Prefix P>(P) {
|
||||
return !requires { typename prefixed_unit<struct kilokelvin, P, kelvin>; };
|
||||
return !requires { typename prefixed_unit<struct kilokilometre, P, kilometre>; };
|
||||
}(si::kilo{})); // no prefix allowed
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user