refactor: simplify dimension_unit

This commit is contained in:
Johel Ernesto Guerrero Peña
2020-09-07 22:25:35 -04:00
committed by Mateusz Pusz
parent 88c4ef07b0
commit 7fb8b456bc

View File

@@ -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.