feat: DerivedDimensionExpr removed

This commit is contained in:
Mateusz Pusz
2024-10-26 19:14:11 +02:00
parent 424f9665db
commit 48fcbb8030
2 changed files with 8 additions and 22 deletions

View File

@@ -52,20 +52,23 @@ import std;
namespace mp_units {
template<detail::DerivedDimensionExpr... Expr>
template<typename... Expr>
struct derived_dimension;
MP_UNITS_EXPORT struct dimension_one;
namespace detail {
template<typename T>
struct is_dimension_one : std::false_type {};
template<typename Lhs, typename Rhs>
struct base_dimension_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
template<typename T1, typename T2>
using type_list_of_base_dimension_less = expr_less<T1, T2, base_dimension_less>;
template<DerivedDimensionExpr... Expr>
template<typename... Expr>
struct derived_dimension_impl : expr_fractions<is_dimension_one, Expr...> {};
struct dimension_interface {
@@ -165,7 +168,7 @@ struct base_dimension : detail::dimension_interface {
* @note User should not instantiate this type! It is not exported from the C++ module. The library will
* instantiate this type automatically based on the dimensional arithmetic equation provided by the user.
*/
template<detail::DerivedDimensionExpr... Expr>
template<typename... Expr>
struct derived_dimension final : detail::dimension_interface, detail::derived_dimension_impl<Expr...> {};
/**
@@ -250,14 +253,14 @@ constexpr auto dimension_symbol_impl(Out out, const power<F, Num, Den...>&, cons
return copy_symbol_exponent<CharT, Num, Den...>(fmt.encoding, negative_power, out);
}
template<typename CharT, std::output_iterator<CharT> Out, DerivedDimensionExpr... Ms>
template<typename CharT, std::output_iterator<CharT> Out, typename... Ms>
constexpr Out dimension_symbol_impl(Out out, const type_list<Ms...>&, const dimension_symbol_formatting& fmt,
bool negative_power)
{
return (..., (out = dimension_symbol_impl<CharT>(out, Ms{}, fmt, negative_power)));
}
template<typename CharT, std::output_iterator<CharT> Out, DerivedDimensionExpr... Nums, DerivedDimensionExpr... Dens>
template<typename CharT, std::output_iterator<CharT> Out, typename... Nums, typename... Dens>
constexpr Out dimension_symbol_impl(Out out, const type_list<Nums...>& nums, const type_list<Dens...>& dens,
const dimension_symbol_formatting& fmt)
{

View File

@@ -57,23 +57,6 @@ namespace detail {
template<typename T>
concept BaseDimension = Dimension<T> && is_derived_from_specialization_of_v<T, base_dimension>;
template<typename T>
struct is_dimension_one : std::false_type {};
template<typename T>
concept IsPowerOfDim =
is_specialization_of_power<T> && (BaseDimension<typename T::factor> || is_dimension_one<typename T::factor>::value);
template<typename T>
constexpr bool is_per_of_dims = false;
template<typename... Ts>
constexpr bool is_per_of_dims<per<Ts...>> =
(... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || IsPowerOfDim<Ts>));
template<typename T>
concept DerivedDimensionExpr = BaseDimension<T> || is_dimension_one<T>::value || IsPowerOfDim<T> || is_per_of_dims<T>;
} // namespace detail
/**