Code cleanup
This commit is contained in:
1 parent
312dbf4f81
commit
40ab45b506
3 files changed
+126
-126
No files matched your search
@@ -58,18 +58,18 @@ namespace units {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool concept Exp = detail::is_exp<T>::value;
|
||||
bool concept Exponent = detail::is_exp<T>::value;
|
||||
|
||||
|
||||
// exp_less
|
||||
|
||||
template<Exp E1, Exp E2>
|
||||
template<Exponent E1, Exponent E2>
|
||||
struct exp_less : dim_id_less<typename E1::dimension, typename E2::dimension> {
|
||||
};
|
||||
|
||||
// exp_invert
|
||||
|
||||
template<Exp Exponent>
|
||||
template<Exponent E>
|
||||
struct exp_invert;
|
||||
|
||||
template<typename BaseDimension, int Value>
|
||||
@@ -77,21 +77,21 @@ namespace units {
|
||||
using type = exp<BaseDimension, -Value>;
|
||||
};
|
||||
|
||||
template<Exp Exponent>
|
||||
using exp_invert_t = typename exp_invert<Exponent>::type;
|
||||
template<Exponent E>
|
||||
using exp_invert_t = typename exp_invert<E>::type;
|
||||
|
||||
// dimension
|
||||
|
||||
template<Exp... Exponents>
|
||||
using dimension = mp::type_list<Exponents...>;
|
||||
template<Exponent... Es>
|
||||
using dimension = mp::type_list<Es...>;
|
||||
|
||||
// is_dimension
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
struct is_dimension : std::false_type {};
|
||||
|
||||
template<Exp... Exponents>
|
||||
struct is_dimension<dimension<Exponents...>> : std::bool_constant<(is_exp<Exponents>::value && ...)> {};
|
||||
template<Exponent... Es>
|
||||
struct is_dimension<dimension<Es...>> : std::bool_constant<(is_exp<Es>::value && ...)> {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -113,19 +113,19 @@ namespace units {
|
||||
using type = dimension<>;
|
||||
};
|
||||
|
||||
template<Exp E>
|
||||
template<Exponent E>
|
||||
struct dim_consolidate<dimension<E>> {
|
||||
using type = dimension<E>;
|
||||
};
|
||||
|
||||
template<Exp E1, Exp... ERest>
|
||||
template<Exponent E1, Exponent... ERest>
|
||||
struct dim_consolidate<dimension<E1, ERest...>> {
|
||||
using rest = dim_consolidate_t<dimension<ERest...>>;
|
||||
using type = std::conditional_t<std::is_same_v<rest, dimension<>>, dimension<E1>,
|
||||
mp::type_list_push_front_t<rest, E1>>;
|
||||
};
|
||||
|
||||
template<typename D, int V1, int V2, Exp... ERest>
|
||||
template<typename D, int V1, int V2, Exponent... ERest>
|
||||
struct dim_consolidate<dimension<exp<D, V1>, exp<D, V2>, ERest...>> {
|
||||
using type = std::conditional_t<V1 + V2 == 0, dim_consolidate_t<dimension<ERest...>>,
|
||||
dim_consolidate_t<dimension<exp<D, V1 + V2>, ERest...>>>;
|
||||
@@ -133,13 +133,13 @@ namespace units {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<Exp... Exponents>
|
||||
template<Exponent... Es>
|
||||
struct make_dimension {
|
||||
using type = detail::dim_consolidate_t<mp::type_list_sort_t<dimension<Exponents...>, exp_less>>;
|
||||
using type = detail::dim_consolidate_t<mp::type_list_sort_t<dimension<Es...>, exp_less>>;
|
||||
};
|
||||
|
||||
template<Exp... Exponents>
|
||||
using make_dimension_t = typename make_dimension<Exponents...>::type;
|
||||
template<Exponent... Es>
|
||||
using make_dimension_t = typename make_dimension<Es...>::type;
|
||||
|
||||
|
||||
|
||||
@@ -148,9 +148,9 @@ namespace units {
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct dimension_multiply;
|
||||
|
||||
template<Exp... Exp1, Exp... Exp2>
|
||||
struct dimension_multiply<dimension<Exp1...>, dimension<Exp2...>> {
|
||||
using type = make_dimension_t<Exp1..., Exp2...>;
|
||||
template<Exponent... E1, Exponent... E2>
|
||||
struct dimension_multiply<dimension<E1...>, dimension<E2...>> {
|
||||
using type = make_dimension_t<E1..., E2...>;
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
@@ -161,9 +161,9 @@ namespace units {
|
||||
template<Dimension D1, Dimension D2>
|
||||
struct dimension_divide;
|
||||
|
||||
template<Exp... Exp1, Exp... Exp2>
|
||||
struct dimension_divide<dimension<Exp1...>, dimension<Exp2...>>
|
||||
: dimension_multiply<dimension<Exp1...>, dimension<exp_invert_t<Exp2>...>> {
|
||||
template<Exponent... E1, Exponent... E2>
|
||||
struct dimension_divide<dimension<E1...>, dimension<E2...>>
|
||||
: dimension_multiply<dimension<E1...>, dimension<exp_invert_t<E2>...>> {
|
||||
};
|
||||
|
||||
template<Dimension D1, Dimension D2>
|
||||
|
||||
Reference in new issue
Block a user