forked from mpusz/mp-units
refactor: is_power_of_quantity_spec
and is_power_of_dim
variable templates converted to concepts
This commit is contained in:
@@ -68,21 +68,19 @@ template<typename T>
|
|||||||
struct is_dimension_one : std::false_type {};
|
struct is_dimension_one : std::false_type {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_power_of_dim = requires {
|
concept IsPowerOfDim =
|
||||||
requires is_specialization_of_power<T> &&
|
is_specialization_of_power<T> && (BaseDimension<typename T::factor> || is_dimension_one<typename T::factor>::value);
|
||||||
(BaseDimension<typename T::factor> || is_dimension_one<typename T::factor>::value);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_per_of_dims = false;
|
constexpr bool is_per_of_dims = false;
|
||||||
|
|
||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
constexpr bool is_per_of_dims<per<Ts...>> =
|
constexpr bool is_per_of_dims<per<Ts...>> =
|
||||||
(... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || is_power_of_dim<Ts>));
|
(... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || IsPowerOfDim<Ts>));
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept DerivedDimensionExpr =
|
concept DerivedDimensionExpr =
|
||||||
BaseDimension<T> || is_dimension_one<T>::value || is_power_of_dim<T> || is_per_of_dims<T>;
|
BaseDimension<T> || is_dimension_one<T>::value || IsPowerOfDim<T> || is_per_of_dims<T>;
|
||||||
|
|
||||||
template<auto D1, auto D2>
|
template<auto D1, auto D2>
|
||||||
concept SameDimension =
|
concept SameDimension =
|
||||||
|
@@ -86,21 +86,20 @@ template<typename T>
|
|||||||
struct is_dimensionless : std::false_type {};
|
struct is_dimensionless : std::false_type {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_power_of_quantity_spec = requires {
|
concept IsPowerOfQuantitySpec = is_specialization_of_power<T> && (NamedQuantitySpec<typename T::factor> ||
|
||||||
requires is_specialization_of_power<T> &&
|
is_dimensionless<typename T::factor>::value);
|
||||||
(NamedQuantitySpec<typename T::factor> || is_dimensionless<typename T::factor>::value);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool is_per_of_quantity_specs = false;
|
constexpr bool is_per_of_quantity_specs = false;
|
||||||
|
|
||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
constexpr bool is_per_of_quantity_specs<per<Ts...>> =
|
constexpr bool is_per_of_quantity_specs<per<Ts...>> =
|
||||||
(... && (NamedQuantitySpec<Ts> || is_dimensionless<Ts>::value || is_power_of_quantity_spec<Ts>));
|
(... && (NamedQuantitySpec<Ts> || is_dimensionless<Ts>::value || IsPowerOfQuantitySpec<Ts>));
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept DerivedQuantitySpecExpr = detail::NamedQuantitySpec<T> || detail::is_dimensionless<T>::value ||
|
concept DerivedQuantitySpecExpr = detail::NamedQuantitySpec<T> || detail::is_dimensionless<T>::value ||
|
||||||
detail::is_power_of_quantity_spec<T> || detail::is_per_of_quantity_specs<T>;
|
detail::IsPowerOfQuantitySpec<T> || detail::is_per_of_quantity_specs<T>;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user