mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 19:04:27 +02:00
refactor: small detail
namespace cleanup for units
This commit is contained in:
@@ -120,18 +120,6 @@ struct get_canonical_unit_result {
|
|||||||
inline static constexpr auto value = get_canonical_unit_impl(U{}, U{});
|
inline static constexpr auto value = get_canonical_unit_impl(U{}, U{});
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Unit Lhs, Unit Rhs>
|
|
||||||
struct unit_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
|
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
|
||||||
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
|
|
||||||
|
|
||||||
template<typename From, typename To>
|
|
||||||
concept PotentiallyConvertibleTo = Unit<From> && Unit<To> &&
|
|
||||||
((AssociatedUnit<From> && AssociatedUnit<To> &&
|
|
||||||
implicitly_convertible(get_quantity_spec(From{}), get_quantity_spec(To{}))) ||
|
|
||||||
(!AssociatedUnit<From> && !AssociatedUnit<To>));
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
// TODO this should really be in the `details` namespace but is used in `chrono.h` (a part of mp_units.systems)
|
// TODO this should really be in the `details` namespace but is used in `chrono.h` (a part of mp_units.systems)
|
||||||
@@ -141,6 +129,16 @@ concept PotentiallyConvertibleTo = Unit<From> && Unit<To> &&
|
|||||||
return detail::get_canonical_unit_result<decltype(u)>::value;
|
return detail::get_canonical_unit_result<decltype(u)>::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template<typename From, typename To>
|
||||||
|
concept PotentiallyConvertibleTo = Unit<From> && Unit<To> &&
|
||||||
|
((AssociatedUnit<From> && AssociatedUnit<To> &&
|
||||||
|
implicitly_convertible(get_quantity_spec(From{}), get_quantity_spec(To{}))) ||
|
||||||
|
(!AssociatedUnit<From> && !AssociatedUnit<To>));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// convertible
|
// convertible
|
||||||
template<Unit From, Unit To>
|
template<Unit From, Unit To>
|
||||||
[[nodiscard]] consteval bool convertible(From from, To to)
|
[[nodiscard]] consteval bool convertible(From from, To to)
|
||||||
@@ -159,6 +157,12 @@ struct derived_unit;
|
|||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
template<Unit Lhs, Unit Rhs>
|
||||||
|
struct unit_less : std::bool_constant<type_name<Lhs>() < type_name<Rhs>()> {};
|
||||||
|
|
||||||
|
template<typename T1, typename T2>
|
||||||
|
using type_list_of_unit_less = expr_less<T1, T2, unit_less>;
|
||||||
|
|
||||||
struct unit_interface {
|
struct unit_interface {
|
||||||
/**
|
/**
|
||||||
* Multiplication by `1` returns the same unit, otherwise `scaled_unit` is being returned.
|
* Multiplication by `1` returns the same unit, otherwise `scaled_unit` is being returned.
|
||||||
|
Reference in New Issue
Block a user