forked from mpusz/mp-units
refactor: ♻️ exp_*
operations on exponents renamed to `exponent_*
This commit is contained in:
@ -43,7 +43,7 @@ constexpr ratio exp_ratio()
|
||||
* @brief Calculates the common ratio of all the references of base units in the derived dimension
|
||||
*/
|
||||
template<typename... Es>
|
||||
constexpr ratio base_units_ratio(exp_list<Es...>)
|
||||
constexpr ratio base_units_ratio(exponent_list<Es...>)
|
||||
{
|
||||
return (exp_ratio<Es>() * ... * ratio(1));
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ template<typename... Es>
|
||||
inline constexpr int negative_exp_count = ((Es::num < 0 ? 1 : 0) + ... + 0);
|
||||
|
||||
template<typename... Us, typename... Es, std::size_t... Idxs>
|
||||
constexpr auto deduced_symbol_text(exp_list<Es...>, std::index_sequence<Idxs...>)
|
||||
constexpr auto deduced_symbol_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
{
|
||||
constexpr auto neg_exp = negative_exp_count<Es...>;
|
||||
return (exp_text<Es, Us::symbol, neg_exp, Idxs>() + ...);
|
||||
|
@ -31,7 +31,7 @@ template<typename ExpList, Unit... Us>
|
||||
inline constexpr bool same_scaled_units = false;
|
||||
|
||||
template<typename... Es, Unit... Us>
|
||||
inline constexpr bool same_scaled_units<exp_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
|
||||
inline constexpr bool same_scaled_units<exponent_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
|
||||
|
||||
// deduced_unit
|
||||
|
||||
@ -45,7 +45,7 @@ constexpr ratio inverse_if_negative(const ratio& r)
|
||||
}
|
||||
|
||||
template<Unit... Us, typename... Es>
|
||||
constexpr ratio derived_ratio(exp_list<Es...>)
|
||||
constexpr ratio derived_ratio(exponent_list<Es...>)
|
||||
{
|
||||
return (... * inverse_if_negative<Es>(pow<detail::abs(Es::num)>(Us::ratio) / dimension_unit<typename Es::dimension>::ratio));
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ namespace units::detail {
|
||||
template<Exponent... Es>
|
||||
requires (BaseDimension<typename Es::dimension> && ...)
|
||||
struct derived_dimension_base : downcast_base<derived_dimension_base<Es...>> {
|
||||
using exponents = exp_list<Es...>;
|
||||
using exponents = exponent_list<Es...>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct to_derived_dimension_base;
|
||||
|
||||
template<Exponent... Es>
|
||||
struct to_derived_dimension_base<exp_list<Es...>> {
|
||||
struct to_derived_dimension_base<exponent_list<Es...>> {
|
||||
using type = derived_dimension_base<Es...>;
|
||||
};
|
||||
|
||||
|
@ -40,28 +40,28 @@ template<typename ExpList>
|
||||
struct dim_consolidate;
|
||||
|
||||
template<>
|
||||
struct dim_consolidate<exp_list<>> {
|
||||
using type = exp_list<>;
|
||||
struct dim_consolidate<exponent_list<>> {
|
||||
using type = exponent_list<>;
|
||||
};
|
||||
|
||||
template<typename E>
|
||||
struct dim_consolidate<exp_list<E>> {
|
||||
using type = exp_list<E>;
|
||||
struct dim_consolidate<exponent_list<E>> {
|
||||
using type = exponent_list<E>;
|
||||
};
|
||||
|
||||
template<typename E1, typename... ERest>
|
||||
struct dim_consolidate<exp_list<E1, ERest...>> {
|
||||
using type = type_list_push_front<typename dim_consolidate<exp_list<ERest...>>::type, E1>;
|
||||
struct dim_consolidate<exponent_list<E1, ERest...>> {
|
||||
using type = type_list_push_front<typename dim_consolidate<exponent_list<ERest...>>::type, E1>;
|
||||
};
|
||||
|
||||
template<BaseDimension Dim, std::intmax_t Num1, std::intmax_t Den1, std::intmax_t Num2, std::intmax_t Den2, typename... ERest>
|
||||
struct dim_consolidate<exp_list<exponent<Dim, Num1, Den1>, exponent<Dim, Num2, Den2>, ERest...>> {
|
||||
struct dim_consolidate<exponent_list<exponent<Dim, Num1, Den1>, exponent<Dim, Num2, Den2>, ERest...>> {
|
||||
// TODO: we have ration_add now, but dim_consolidate etc, now need to cope with our new ratio
|
||||
using r1 = std::ratio<Num1, Den1>;
|
||||
using r2 = std::ratio<Num2, Den2>;
|
||||
using r = std::ratio_add<r1, r2>;
|
||||
using type = conditional<r::num == 0, typename dim_consolidate<exp_list<ERest...>>::type,
|
||||
typename dim_consolidate<exp_list<exponent<Dim, r::num, r::den>, ERest...>>::type>;
|
||||
using type = conditional<r::num == 0, typename dim_consolidate<exponent_list<ERest...>>::type,
|
||||
typename dim_consolidate<exponent_list<exponent<Dim, r::num, r::den>, ERest...>>::type>;
|
||||
};
|
||||
|
||||
} // namespace units::detail
|
||||
|
@ -38,7 +38,7 @@ struct dim_unpack;
|
||||
|
||||
template<>
|
||||
struct dim_unpack<> {
|
||||
using type = exp_list<>;
|
||||
using type = exponent_list<>;
|
||||
};
|
||||
|
||||
template<BaseDimension Dim, std::intmax_t Num, std::intmax_t Den, Exponent... ERest>
|
||||
@ -53,7 +53,7 @@ struct dim_unpack<exponent<Dim, Num, Den>, ERest...> {
|
||||
|
||||
template<Exponent... Es, std::intmax_t Num, std::intmax_t Den, Exponent... ERest>
|
||||
struct dim_unpack<exponent<derived_dimension_base<Es...>, Num, Den>, ERest...> {
|
||||
using type = type_list_push_front<typename dim_unpack<ERest...>::type, exp_multiply<Es, Num, Den>...>;
|
||||
using type = type_list_push_front<typename dim_unpack<ERest...>::type, exponent_multiply<Es, Num, Den>...>;
|
||||
};
|
||||
|
||||
} // namespace units::detail
|
||||
|
@ -122,7 +122,7 @@ struct dim_invert_impl<derived_dimension_base<exponent<D, -1>>> {
|
||||
|
||||
template<typename... Es>
|
||||
struct dim_invert_impl<derived_dimension_base<Es...>> {
|
||||
using type = downcast_dimension<derived_dimension_base<exp_invert<Es>...>>;
|
||||
using type = downcast_dimension<derived_dimension_base<exponent_invert<Es>...>>;
|
||||
};
|
||||
|
||||
template<DerivedDimension D>
|
||||
@ -141,12 +141,12 @@ template<typename T>
|
||||
struct to_dimension;
|
||||
|
||||
template<Exponent... Es>
|
||||
struct to_dimension<exp_list<Es...>> {
|
||||
struct to_dimension<exponent_list<Es...>> {
|
||||
using type = derived_dimension_base<Es...>;
|
||||
};
|
||||
|
||||
template<BaseDimension D>
|
||||
struct to_dimension<exp_list<exponent<D, 1>>> {
|
||||
struct to_dimension<exponent_list<exponent<D, 1>>> {
|
||||
using type = D;
|
||||
};
|
||||
|
||||
@ -160,7 +160,7 @@ struct to_dimension<exp_list<exponent<D, 1>>> {
|
||||
* dimension itself.
|
||||
*/
|
||||
template<Dimension D1, Dimension D2>
|
||||
using merge_dimension = TYPENAME to_dimension<typename dim_consolidate<type_list_merge_sorted<typename D1::exponents, typename D2::exponents, exp_less>>::type>::type;
|
||||
using merge_dimension = TYPENAME to_dimension<typename dim_consolidate<type_list_merge_sorted<typename D1::exponents, typename D2::exponents, exponent_less>>::type>::type;
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct dimension_multiply_impl;
|
||||
@ -216,7 +216,7 @@ struct dimension_sqrt_impl<D> {
|
||||
|
||||
template<typename... Es>
|
||||
struct dimension_sqrt_impl<derived_dimension_base<Es...>> {
|
||||
using type = downcast_dimension<derived_dimension_base<exp_multiply<Es, 1, 2>...>>;
|
||||
using type = downcast_dimension<derived_dimension_base<exponent_multiply<Es, 1, 2>...>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@ -252,7 +252,7 @@ struct dimension_pow_impl<D, N> {
|
||||
|
||||
template<typename... Es, std::intmax_t N>
|
||||
struct dimension_pow_impl<derived_dimension_base<Es...>, N> {
|
||||
using type = downcast_dimension<derived_dimension_base<exp_multiply<Es, N, 1>...>>;
|
||||
using type = downcast_dimension<derived_dimension_base<exponent_multiply<Es, N, 1>...>>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@ -103,40 +103,40 @@ constexpr auto prefix_or_ratio_text()
|
||||
}
|
||||
|
||||
template<typename... Es, std::size_t... Idxs>
|
||||
constexpr auto derived_dimension_unit_text(exp_list<Es...>, std::index_sequence<Idxs...>)
|
||||
constexpr auto derived_dimension_unit_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
{
|
||||
return (exp_text<Es, dimension_unit<typename Es::dimension>::symbol, negative_exp_count<Es...>, Idxs>() + ... + basic_symbol_text(basic_fixed_string("")));
|
||||
}
|
||||
|
||||
template<typename... Es>
|
||||
constexpr auto derived_dimension_unit_text(exp_list<Es...> list)
|
||||
constexpr auto derived_dimension_unit_text(exponent_list<Es...> list)
|
||||
{
|
||||
return derived_dimension_unit_text(list, std::index_sequence_for<Es...>());
|
||||
}
|
||||
|
||||
template<Exponent... Es>
|
||||
constexpr auto exp_list_with_named_units(exp_list<Es...>);
|
||||
constexpr auto exponent_list_with_named_units(exponent_list<Es...>);
|
||||
|
||||
template<Exponent Exp>
|
||||
constexpr auto exp_list_with_named_units(Exp)
|
||||
constexpr auto exponent_list_with_named_units(Exp)
|
||||
{
|
||||
using dim = TYPENAME Exp::dimension;
|
||||
if constexpr(dimension_unit<dim>::is_named) {
|
||||
return exp_list<Exp>();
|
||||
return exponent_list<Exp>();
|
||||
}
|
||||
else {
|
||||
using recipe = TYPENAME dim::recipe;
|
||||
return exp_list_with_named_units(recipe());
|
||||
return exponent_list_with_named_units(recipe());
|
||||
}
|
||||
}
|
||||
|
||||
template<Exponent... Es>
|
||||
constexpr auto exp_list_with_named_units(exp_list<Es...>)
|
||||
constexpr auto exponent_list_with_named_units(exponent_list<Es...>)
|
||||
{
|
||||
return type_list_join<decltype(exp_list_with_named_units(Es()))...>();
|
||||
return type_list_join<decltype(exponent_list_with_named_units(Es()))...>();
|
||||
}
|
||||
|
||||
constexpr auto exp_list_with_named_units(exp_list<> empty)
|
||||
constexpr auto exponent_list_with_named_units(exponent_list<> empty)
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
@ -145,7 +145,7 @@ template<Dimension Dim>
|
||||
constexpr auto derived_dimension_unit_text()
|
||||
{
|
||||
using recipe = TYPENAME Dim::recipe;
|
||||
return derived_dimension_unit_text(exp_list_with_named_units(recipe()));
|
||||
return derived_dimension_unit_text(exponent_list_with_named_units(recipe()));
|
||||
}
|
||||
|
||||
// TODO Inline below concept when switched to gcc-10
|
||||
|
@ -46,7 +46,7 @@ namespace detail {
|
||||
* this base dimension.
|
||||
*/
|
||||
template<Exponent... Es>
|
||||
using make_dimension = TYPENAME to_derived_dimension_base<typename dim_consolidate<type_list_sort<typename dim_unpack<Es...>::type, exp_less>>::type>::type;
|
||||
using make_dimension = TYPENAME to_derived_dimension_base<typename dim_consolidate<type_list_sort<typename dim_unpack<Es...>::type, exponent_less>>::type>::type;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@ -79,7 +79,7 @@ using make_dimension = TYPENAME to_derived_dimension_base<typename dim_consolida
|
||||
*/
|
||||
template<typename Child, Unit U, Exponent... Es>
|
||||
struct derived_dimension : downcast_child<Child, typename detail::make_dimension<Es...>> {
|
||||
using recipe = exp_list<Es...>;
|
||||
using recipe = exponent_list<Es...>;
|
||||
using coherent_unit = U;
|
||||
static constexpr ratio base_units_ratio = detail::base_units_ratio(typename derived_dimension::exponents());
|
||||
};
|
||||
|
@ -49,27 +49,27 @@ inline constexpr bool is_exponent<exponent<Dim, Num, Den>> = true;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// exp_less
|
||||
// exponent_less
|
||||
template<Exponent E1, Exponent E2>
|
||||
requires BaseDimension<typename E1::dimension> && BaseDimension<typename E2::dimension>
|
||||
struct exp_less : base_dimension_less<typename E1::dimension, typename E2::dimension> {};
|
||||
struct exponent_less : base_dimension_less<typename E1::dimension, typename E2::dimension> {};
|
||||
|
||||
// exp_invert
|
||||
// exponent_invert
|
||||
namespace detail {
|
||||
|
||||
template<typename Dim, std::intmax_t Num, std::intmax_t Den>
|
||||
constexpr exponent<Dim, -Num, Den> exp_invert_impl(exponent<Dim, Num, Den>);
|
||||
constexpr exponent<Dim, -Num, Den> exponent_invert_impl(exponent<Dim, Num, Den>);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<Exponent E>
|
||||
using exp_invert = decltype(detail::exp_invert_impl(E()));
|
||||
using exponent_invert = decltype(detail::exponent_invert_impl(E()));
|
||||
|
||||
// exp_multiply
|
||||
// exponent_multiply
|
||||
namespace detail {
|
||||
|
||||
template<Exponent E, std::intmax_t Num, std::intmax_t Den>
|
||||
struct exp_multiply_impl {
|
||||
struct exponent_multiply_impl {
|
||||
static constexpr ratio r = ratio(E::num, E::den) * ratio(Num, Den);
|
||||
using type = exponent<typename E::dimension, r.num, r.den>;
|
||||
};
|
||||
@ -77,9 +77,9 @@ struct exp_multiply_impl {
|
||||
} // namespace detail
|
||||
|
||||
template<Exponent E, std::intmax_t Num, std::intmax_t Den>
|
||||
using exp_multiply = TYPENAME detail::exp_multiply_impl<E, Num, Den>::type;
|
||||
using exponent_multiply = TYPENAME detail::exponent_multiply_impl<E, Num, Den>::type;
|
||||
|
||||
template<Exponent... Es>
|
||||
struct exp_list {};
|
||||
struct exponent_list {};
|
||||
|
||||
} // namespace units
|
||||
|
@ -84,21 +84,21 @@ namespace units {
|
||||
// exp_dim_id_less
|
||||
|
||||
template<Exponent E1, Exponent E2>
|
||||
struct exp_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
struct exponent_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
};
|
||||
|
||||
// exp_invert
|
||||
// exponent_invert
|
||||
|
||||
template<Exponent E>
|
||||
struct exp_invert;
|
||||
struct exponent_invert;
|
||||
|
||||
template<const base_dimension& BaseDimension, std::intmax_t Num, std::intmax_t Den>
|
||||
struct exp_invert<exponent<BaseDimension, Num, Den>> {
|
||||
struct exponent_invert<exponent<BaseDimension, Num, Den>> {
|
||||
using type = exponent<BaseDimension, -Num, Den>;
|
||||
};
|
||||
|
||||
template<Exponent E>
|
||||
using exp_invert_t = exp_invert<E>::type;
|
||||
using exponent_invert_t = exponent_invert<E>::type;
|
||||
|
||||
// dimension
|
||||
|
||||
@ -128,7 +128,7 @@ namespace units {
|
||||
struct dim_invert;
|
||||
|
||||
template<Exponent... Es>
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exp_invert_t<Es>...>>> {};
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exponent_invert_t<Es>...>>> {};
|
||||
|
||||
template<Dimension D>
|
||||
using dim_invert_t = dim_invert<typename D::downcast_base_type>::type;
|
||||
@ -173,7 +173,7 @@ namespace units {
|
||||
|
||||
template<Exponent... Es>
|
||||
struct make_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exponent_less>>;
|
||||
};
|
||||
|
||||
template<Exponent... Es>
|
||||
@ -181,7 +181,7 @@ namespace units {
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct merge_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exponent_less>>;
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
@ -205,7 +205,7 @@ namespace units {
|
||||
|
||||
template<Exponent... E1, Exponent... E2>
|
||||
struct dimension_divide<dimension<E1...>, dimension<E2...>>
|
||||
: dimension_multiply<dimension<E1...>, dimension<exp_invert_t<E2>...>> {
|
||||
: dimension_multiply<dimension<E1...>, dimension<exponent_invert_t<E2>...>> {
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
|
@ -84,21 +84,21 @@ namespace units {
|
||||
// exp_dim_id_less
|
||||
|
||||
template<Exponent E1, Exponent E2>
|
||||
struct exp_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
struct exponent_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
};
|
||||
|
||||
// exp_invert
|
||||
// exponent_invert
|
||||
|
||||
template<Exponent E>
|
||||
struct exp_invert;
|
||||
struct exponent_invert;
|
||||
|
||||
template<const base_dimension& BaseDimension, std::intmax_t Num, std::intmax_t Den>
|
||||
struct exp_invert<exponent<BaseDimension, Num, Den>> {
|
||||
struct exponent_invert<exponent<BaseDimension, Num, Den>> {
|
||||
using type = exponent<BaseDimension, -Num, Den>;
|
||||
};
|
||||
|
||||
template<Exponent E>
|
||||
using exp_invert_t = exp_invert<E>::type;
|
||||
using exponent_invert_t = exponent_invert<E>::type;
|
||||
|
||||
// dimension
|
||||
|
||||
@ -128,7 +128,7 @@ namespace units {
|
||||
struct dim_invert;
|
||||
|
||||
template<typename... Es>
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exp_invert_t<Es>...>>> {};
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exponent_invert_t<Es>...>>> {};
|
||||
|
||||
template<Dimension D>
|
||||
using dim_invert_t = dim_invert<typename D::downcast_base_type>::type;
|
||||
@ -173,7 +173,7 @@ namespace units {
|
||||
|
||||
template<Exponent... Es>
|
||||
struct make_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exponent_less>>;
|
||||
};
|
||||
|
||||
template<Exponent... Es>
|
||||
@ -181,7 +181,7 @@ namespace units {
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct merge_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exponent_less>>;
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
@ -205,7 +205,7 @@ namespace units {
|
||||
|
||||
template<typename... E1, typename... E2>
|
||||
struct dimension_divide<dimension<E1...>, dimension<E2...>>
|
||||
: dimension_multiply<dimension<E1...>, dimension<exp_invert_t<E2>...>> {
|
||||
: dimension_multiply<dimension<E1...>, dimension<exponent_invert_t<E2>...>> {
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
|
@ -72,21 +72,21 @@ namespace units {
|
||||
// exp_dim_id_less
|
||||
|
||||
template<typename E1, typename E2>
|
||||
struct exp_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
struct exponent_less : base_dimension_less<E1::dimension, E2::dimension> {
|
||||
};
|
||||
|
||||
// exp_invert
|
||||
// exponent_invert
|
||||
|
||||
template<typename E>
|
||||
struct exp_invert;
|
||||
struct exponent_invert;
|
||||
|
||||
template<const base_dimension& BaseDimension, std::intmax_t Num, std::intmax_t Den>
|
||||
struct exp_invert<exponent<BaseDimension, Num, Den>> {
|
||||
struct exponent_invert<exponent<BaseDimension, Num, Den>> {
|
||||
using type = exponent<BaseDimension, -Num, Den>;
|
||||
};
|
||||
|
||||
template<typename E>
|
||||
using exp_invert_t = exp_invert<E>::type;
|
||||
using exponent_invert_t = exponent_invert<E>::type;
|
||||
|
||||
// dimension
|
||||
|
||||
@ -99,7 +99,7 @@ namespace units {
|
||||
struct dim_invert;
|
||||
|
||||
template<typename... Es>
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exp_invert_t<Es>...>>> {};
|
||||
struct dim_invert<dimension<Es...>> : std::type_identity<downcast_traits_t<dimension<exponent_invert_t<Es>...>>> {};
|
||||
|
||||
template<typename D>
|
||||
using dim_invert_t = dim_invert<typename D::downcast_base_type>::type;
|
||||
@ -144,7 +144,7 @@ namespace units {
|
||||
|
||||
template<typename... Es>
|
||||
struct make_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_sort<dimension<Es...>, exponent_less>>;
|
||||
};
|
||||
|
||||
template<typename... Es>
|
||||
@ -152,7 +152,7 @@ namespace units {
|
||||
|
||||
template<typename D1, typename D2>
|
||||
struct merge_dimension {
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<type_list_merge_sorted<D1, D2, exponent_less>>;
|
||||
};
|
||||
|
||||
template<typename D1, typename D2>
|
||||
@ -176,7 +176,7 @@ namespace units {
|
||||
|
||||
template<typename... E1, typename... E2>
|
||||
struct dimension_divide<dimension<E1...>, dimension<E2...>>
|
||||
: dimension_multiply<dimension<E1...>, dimension<exp_invert_t<E2>...>> {
|
||||
: dimension_multiply<dimension<E1...>, dimension<exponent_invert_t<E2>...>> {
|
||||
};
|
||||
|
||||
template<typename D1, typename D2>
|
||||
|
@ -37,10 +37,10 @@ struct d2 : base_dimension<"d2", u2> {};
|
||||
struct u3 : named_unit<u3, "u3", no_prefix> {};
|
||||
struct d3 : base_dimension<"d3", u3> {};
|
||||
|
||||
// exp_invert
|
||||
// exponent_invert
|
||||
|
||||
static_assert(is_same_v<exp_invert<units::exponent<d0, 2>>, units::exponent<d0, -2>>);
|
||||
static_assert(is_same_v<exp_invert<units::exponent<d1, -2>>, units::exponent<d1, 2>>);
|
||||
static_assert(is_same_v<exponent_invert<units::exponent<d0, 2>>, units::exponent<d0, -2>>);
|
||||
static_assert(is_same_v<exponent_invert<units::exponent<d1, -2>>, units::exponent<d1, 2>>);
|
||||
|
||||
// dim_unpack
|
||||
|
||||
@ -53,14 +53,14 @@ using dim_unpack = TYPENAME detail::dim_unpack<Ts...>::type;
|
||||
template<Exponent... Es>
|
||||
using derived_dim = detail::derived_dimension_base<Es...>;
|
||||
|
||||
static_assert(is_same_v<dim_unpack<>, exp_list<>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>>, exp_list<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>, units::exponent<d1, 2>>, exp_list<units::exponent<d0, 1>, units::exponent<d1, 2>>>);
|
||||
static_assert(is_same_v<dim_unpack<>, exponent_list<>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>>, exponent_list<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<d0, 1>, units::exponent<d1, 2>>, exponent_list<units::exponent<d0, 1>, units::exponent<d1, 2>>>);
|
||||
using dim1 = derived_dim<units::exponent<d0, 1>>;
|
||||
using dim2 = derived_dim<units::exponent<d0, 1>, units::exponent<d1, 2>>;
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<dim1, 2>, units::exponent<d0, 1>>, exp_list<units::exponent<d0, 2>, units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<dim1, 2>, units::exponent<d0, 1>>, exponent_list<units::exponent<d0, 2>, units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<dim_unpack<units::exponent<dim2, -2>, units::exponent<d0, 1>, units::exponent<d1, 2>>,
|
||||
exp_list<units::exponent<d0, -2>, units::exponent<d1, -4>, units::exponent<d0, 1>, units::exponent<d1, 2>>>);
|
||||
exponent_list<units::exponent<d0, -2>, units::exponent<d1, -4>, units::exponent<d0, 1>, units::exponent<d1, 2>>>);
|
||||
|
||||
// dim_invert
|
||||
static_assert(is_same_v<dim_invert<derived_dim<units::exponent<d0, -1>>>, d0>);
|
||||
|
@ -98,20 +98,20 @@ struct d0 : base_dimension<"d0", u0> {};
|
||||
struct u1 : named_unit<u1, "u1", no_prefix> {};
|
||||
struct d1 : base_dimension<"d1", u1> {};
|
||||
|
||||
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exponent<d0, 1>>, type_list<units::exponent<d1, 1>>, exp_less>,
|
||||
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exponent<d0, 1>>, type_list<units::exponent<d1, 1>>, exponent_less>,
|
||||
type_list<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exponent<d1, 1>>, type_list<units::exponent<d0, 1>>, exp_less>,
|
||||
static_assert(is_same_v<type_list_merge_sorted<type_list<units::exponent<d1, 1>>, type_list<units::exponent<d0, 1>>, exponent_less>,
|
||||
type_list<units::exponent<d0, 1>, units::exponent<d1, 1>>>);
|
||||
|
||||
// type_list_sort
|
||||
|
||||
template<TypeList List>
|
||||
using exp_sort = type_list_sort<List, exp_less>;
|
||||
using exp_sort = type_list_sort<List, exponent_less>;
|
||||
|
||||
static_assert(is_same_v<exp_sort<exp_list<units::exponent<d0, 1>>>, exp_list<units::exponent<d0, 1>>>);
|
||||
static_assert(is_same_v<exp_sort<exponent_list<units::exponent<d0, 1>>>, exponent_list<units::exponent<d0, 1>>>);
|
||||
static_assert(
|
||||
is_same_v<exp_sort<exp_list<units::exponent<d0, 1>, units::exponent<d1, -1>>>, exp_list<units::exponent<d0, 1>, units::exponent<d1, -1>>>);
|
||||
is_same_v<exp_sort<exponent_list<units::exponent<d0, 1>, units::exponent<d1, -1>>>, exponent_list<units::exponent<d0, 1>, units::exponent<d1, -1>>>);
|
||||
static_assert(
|
||||
is_same_v<exp_sort<exp_list<units::exponent<d1, 1>, units::exponent<d0, -1>>>, exp_list<units::exponent<d0, -1>, units::exponent<d1, 1>>>);
|
||||
is_same_v<exp_sort<exponent_list<units::exponent<d1, 1>, units::exponent<d0, -1>>>, exponent_list<units::exponent<d0, -1>, units::exponent<d1, 1>>>);
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user