diff --git a/example/v2_framework.cpp b/example/v2_framework.cpp index 34c0a3c8..abc075cd 100644 --- a/example/v2_framework.cpp +++ b/example/v2_framework.cpp @@ -34,16 +34,16 @@ inline constexpr struct activity : system_reference // check for invalid prefixes -template -concept can_not_be_prefixed = !requires { typename si::milli_; }; +template typename prefix, Unit auto V1> +concept can_not_be_prefixed = !requires { typename prefix; }; -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); -static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); +static_assert(can_not_be_prefixed); // Named quantity/dimension and unit static_assert( diff --git a/src/core/include/units/unit.h b/src/core/include/units/unit.h index 12e499d1..4dd877fb 100644 --- a/src/core/include/units/unit.h +++ b/src/core/include/units/unit.h @@ -92,6 +92,9 @@ concept NamedUnit = Unit && requires(T* t) { detail::to_base_specialization_o template inline constexpr bool unit_can_be_prefixed = NamedUnit>; +template +concept PrefixableUnit = NamedUnit && unit_can_be_prefixed; + /** * @brief A prefixed unit * @@ -103,8 +106,7 @@ inline constexpr bool unit_can_be_prefixed = NamedUnit - requires unit_can_be_prefixed +template struct prefixed_unit : std::remove_const_t { static constexpr auto symbol = Symbol + U.symbol; }; diff --git a/src/systems/si/include/units/si/prefixes.h b/src/systems/si/include/units/si/prefixes.h index f90bdbde..eba32a3c 100644 --- a/src/systems/si/include/units/si/prefixes.h +++ b/src/systems/si/include/units/si/prefixes.h @@ -26,86 +26,86 @@ namespace units::si { -template +template struct yocto_ : prefixed_unit<"y", mag_power<10, -24>, U> {}; -template +template struct zepto_ : prefixed_unit<"z", mag_power<10, -21>, U> {}; -template +template struct atto_ : prefixed_unit<"a", mag_power<10, -18>, U> {}; -template +template struct femto_ : prefixed_unit<"f", mag_power<10, -15>, U> {}; -template +template struct pico_ : prefixed_unit<"p", mag_power<10, -12>, U> {}; -template +template struct nano_ : prefixed_unit<"n", mag_power<10, -9>, U> {}; -template +template struct micro_ : prefixed_unit, U> {}; -template +template struct milli_ : prefixed_unit<"m", mag_power<10, -3>, U> {}; -template +template struct centi_ : prefixed_unit<"c", mag_power<10, -2>, U> {}; -template +template struct deci_ : prefixed_unit<"d", mag_power<10, -1>, U> {}; -template +template struct deca_ : prefixed_unit<"da", mag_power<10, 1>, U> {}; -template +template struct hecto_ : prefixed_unit<"h", mag_power<10, 2>, U> {}; -template +template struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U> {}; -template +template struct mega_ : prefixed_unit<"M", mag_power<10, 6>, U> {}; -template +template struct giga_ : prefixed_unit<"G", mag_power<10, 9>, U> {}; -template +template struct tera_ : prefixed_unit<"T", mag_power<10, 12>, U> {}; -template +template struct peta_ : prefixed_unit<"P", mag_power<10, 15>, U> {}; -template +template struct exa_ : prefixed_unit<"E", mag_power<10, 18>, U> {}; -template +template struct zetta_ : prefixed_unit<"Z", mag_power<10, 21>, U> {}; -template +template struct yotta_ : prefixed_unit<"Y", mag_power<10, 24>, U> {}; -template +template inline constexpr yocto_ yocto; -template +template inline constexpr zepto_ zepto; -template +template inline constexpr atto_ atto; -template +template inline constexpr femto_ femto; -template +template inline constexpr pico_ pico; -template +template inline constexpr nano_ nano; -template +template inline constexpr micro_ micro; -template +template inline constexpr milli_ milli; -template +template inline constexpr centi_ centi; -template +template inline constexpr deci_ deci; -template +template inline constexpr deca_ deca; -template +template inline constexpr hecto_ hecto; -template +template inline constexpr kilo_ kilo; -template +template inline constexpr mega_ mega; -template +template inline constexpr giga_ giga; -template +template inline constexpr tera_ tera; -template +template inline constexpr peta_ peta; -template +template inline constexpr exa_ exa; -template +template inline constexpr zetta_ zetta; -template +template inline constexpr yotta_ yotta; } // namespace units::si