PrefixType renamed to PrefixFamily + units hierarchy PNG fixed
This commit is contained in:
1 parent
a9432b1407
commit
034f239f96
10 files changed
+146
-68
No files matched your search
@@ -42,11 +42,16 @@ concept basic_arithmetic = // exposition only
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// PrefixType
|
||||
struct prefix_type;
|
||||
// PrefixFamily
|
||||
struct prefix_family;
|
||||
|
||||
/**
|
||||
* @brief A concept matching a prefix family
|
||||
*
|
||||
* Satisfied by all types derived from `prefix_family`
|
||||
*/
|
||||
template<typename T>
|
||||
concept PrefixType = std::derived_from<T, prefix_type>;
|
||||
concept PrefixFamily = std::derived_from<T, prefix_family>;
|
||||
|
||||
// Prefix
|
||||
// TODO gcc:92150
|
||||
@@ -56,11 +61,16 @@ concept PrefixType = std::derived_from<T, prefix_type>;
|
||||
// template<typename T>
|
||||
// inline constexpr bool is_prefix = false;
|
||||
|
||||
// template<typename PrefixType, Ratio R, basic_fixed_string Symbol>
|
||||
// inline constexpr bool is_prefix<prefix<PrefixType, R, Symbol>> = true;
|
||||
// template<typename PrefixFamily, Ratio R, basic_fixed_string Symbol>
|
||||
// inline constexpr bool is_prefix<prefix<PrefixFamily, R, Symbol>> = true;
|
||||
|
||||
// } // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching a symbol prefix
|
||||
*
|
||||
* Satisfied by all instantiations of `prefix`.
|
||||
*/
|
||||
template<typename T>
|
||||
// concept Prefix = detail::is_prefix<T>;
|
||||
concept Prefix = true;
|
||||
@@ -73,11 +83,19 @@ inline constexpr bool is_ratio = false;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching a ratio
|
||||
*
|
||||
* Satisfied by all instantiations of `ratio`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Ratio = detail::is_ratio<T>;
|
||||
|
||||
|
||||
// UnitRatio
|
||||
/**
|
||||
* @brief A concept matching unit's ratio
|
||||
*
|
||||
* Satisfied by all types that satisfy `Ratio<R>` and for which `R::num > 0` and `R::den > 0`
|
||||
*/
|
||||
template<typename R>
|
||||
concept UnitRatio = Ratio<R> && R::num > 0 && R::den > 0; // double negatives not allowed
|
||||
|
||||
@@ -85,10 +103,14 @@ concept UnitRatio = Ratio<R> && R::num > 0 && R::den > 0; // double negatives no
|
||||
template<UnitRatio R, typename U>
|
||||
struct scaled_unit;
|
||||
|
||||
/**
|
||||
* @brief A concept matching all unit types in the library
|
||||
*
|
||||
* Satisfied by all unit types derived from the instantiation of :class:`scaled_unit`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Unit = is_derived_from_instantiation<T, scaled_unit>;
|
||||
|
||||
// BaseDimension
|
||||
template<basic_fixed_string Symbol, Unit U>
|
||||
requires U::is_named
|
||||
struct base_dimension;
|
||||
@@ -112,6 +134,11 @@ inline constexpr bool is_base_dimension<base_dimension<Name, Params...>> = true;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching all base dimensions in the library.
|
||||
*
|
||||
* Satisfied by all dimension types derived from the instantiation of `base_dimension`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept BaseDimension = detail::is_base_dimension<typename T::base_type_workaround>;
|
||||
|
||||
@@ -123,6 +150,11 @@ inline constexpr bool is_exp = false;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching dimension's exponents.
|
||||
*
|
||||
* Satisfied by all instantiations of :class:`exp`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Exponent = detail::is_exp<T>;
|
||||
|
||||
@@ -135,10 +167,20 @@ struct derived_dimension_base;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching all derived dimensions in the library.
|
||||
*
|
||||
* Satisfied by all dimension types derived from the instantiation of `detail::derived_dimension_base`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept DerivedDimension = is_instantiation<downcast_base_t<T>, detail::derived_dimension_base>;
|
||||
|
||||
// Dimension
|
||||
/**
|
||||
* @brief A concept matching all dimensions in the library.
|
||||
*
|
||||
* Satisfied by all dimension types for which either `BaseDimension<T>` or `DerivedDimension<T>` is `true`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Dimension = BaseDimension<T> || DerivedDimension<T>;
|
||||
|
||||
@@ -163,6 +205,15 @@ struct dimension_unit_impl<D> {
|
||||
template<Dimension D>
|
||||
using dimension_unit = detail::dimension_unit_impl<D>::type;
|
||||
|
||||
/**
|
||||
* @brief A concept matching only units of a specified dimension.
|
||||
*
|
||||
* Satisfied by all unit types that satisfy `Unit<U>`, `Dimension<D>`, and for which
|
||||
* `U::reference` and `dimension_unit<D>::reference` denote the same unit type.
|
||||
*
|
||||
* @tparam U Type to verify.
|
||||
* @tparam D Dimension type to use for verification.
|
||||
*/
|
||||
template<typename U, typename D>
|
||||
concept UnitOf =
|
||||
Unit<U> &&
|
||||
@@ -177,6 +228,11 @@ inline constexpr bool is_quantity = false;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching all quantities in the library.
|
||||
*
|
||||
* Satisfied by all instantiations of :class:`quantity`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Quantity = detail::is_quantity<T>;
|
||||
|
||||
@@ -193,11 +249,22 @@ inline constexpr bool is_wrapped_quantity<T> = Quantity<typename T::value_type>
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
* @brief A concept matching types that wrap quantity objects.
|
||||
*
|
||||
* Satisfied by all wrapper types that satisfy `Quantity<typename T::value_type>`
|
||||
* recursively (i.e. `std::optional<si::length<si::metre>>`).
|
||||
*/
|
||||
template<typename T>
|
||||
concept WrappedQuantity = detail::is_wrapped_quantity<T>;
|
||||
|
||||
// Scalar
|
||||
/**
|
||||
* @brief A concept matching non-Quantity types.
|
||||
*
|
||||
* Satisfied by types that satisfy `(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
||||
*/
|
||||
template<typename T>
|
||||
concept Scalar = (!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>; // && std::totally_ordered<T>;// && detail::basic_arithmetic<T>;
|
||||
concept Scalar = (!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>; // TODO: && std::totally_ordered<T>;// && detail::basic_arithmetic<T>;
|
||||
|
||||
} // namespace units
|
||||
Reference in new issue
Block a user