mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
refactor: simplify dimension_unit
This commit is contained in:
committed by
Mateusz Pusz
parent
88c4ef07b0
commit
7fb8b456bc
@@ -165,17 +165,13 @@ concept Dimension = BaseDimension<T> || DerivedDimension<T>;
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<Dimension D>
|
template<Dimension D>
|
||||||
struct dimension_unit_impl;
|
auto default_unit()
|
||||||
|
{
|
||||||
template<BaseDimension D>
|
if constexpr (BaseDimension<D>)
|
||||||
struct dimension_unit_impl<D> {
|
return TYPENAME D::base_unit{};
|
||||||
using type = TYPENAME D::base_unit;
|
else
|
||||||
};
|
return TYPENAME D::coherent_unit{};
|
||||||
|
}
|
||||||
template<DerivedDimension D>
|
|
||||||
struct dimension_unit_impl<D> {
|
|
||||||
using type = TYPENAME D::coherent_unit;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@@ -188,7 +184,7 @@ struct dimension_unit_impl<D> {
|
|||||||
* @tparam D Dimension type to get the unit from.
|
* @tparam D Dimension type to get the unit from.
|
||||||
*/
|
*/
|
||||||
template<Dimension D>
|
template<Dimension D>
|
||||||
using dimension_unit = TYPENAME detail::dimension_unit_impl<D>::type;
|
using dimension_unit = decltype(detail::default_unit<D>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A concept matching only units of a specified dimension.
|
* @brief A concept matching only units of a specified dimension.
|
||||||
|
Reference in New Issue
Block a user