Skip to content

Commit

Permalink
feat: DerivedDimensionExpr removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Oct 26, 2024
1 parent 424f966 commit 48fcbb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
13 changes: 8 additions & 5 deletions src/core/include/mp-units/framework/dimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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...> {};

/**
Expand Down Expand Up @@ -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)
{
Expand Down
17 changes: 0 additions & 17 deletions src/core/include/mp-units/framework/dimension_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down

0 comments on commit 48fcbb8

Please sign in to comment.