refactor: unnecessary custom versions of is_specialization_of removed

This commit is contained in:
Mateusz Pusz
2024-09-23 14:17:49 +02:00
parent 3671f64153
commit dca6bc3555
4 changed files with 4 additions and 33 deletions

View File

@@ -56,12 +56,6 @@ struct per {};
namespace detail {
template<typename T>
constexpr bool is_specialization_of_per = false;
template<typename... Ts>
constexpr bool is_specialization_of_per<per<Ts...>> = true;
template<int Num, int... Den>
constexpr bool valid_ratio = true;
@@ -312,7 +306,7 @@ template<template<typename> typename OneType, typename List>
else {
using last_element = type_list_back<List>;
if constexpr (is_specialization_of_per<last_element>) {
if constexpr (is_specialization_of<last_element, per>) {
if constexpr (size == 2 && OneType<type_list_front<List>>::value)
return expr_fractions_result<type_list<>, type_list_map<last_element, type_list>>{};
else {

View File

@@ -53,13 +53,7 @@ struct kind_of_;
namespace detail {
template<typename T>
constexpr bool is_specialization_of_kind_of = false;
template<typename Q>
constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true;
template<typename T>
concept QuantityKindSpec = is_specialization_of_kind_of<T>;
concept QuantityKindSpec = is_specialization_of<T, kind_of_>;
#if MP_UNITS_API_NO_CRTP
template<auto... Args>

View File

@@ -32,17 +32,6 @@ namespace mp_units {
MP_UNITS_EXPORT template<QuantitySpec Q, Unit U>
struct reference;
namespace detail {
// do not refactor below to a variable template - GCC-11 does not like it
template<typename T>
struct is_specialization_of_reference : std::false_type {};
template<typename Q, typename U>
struct is_specialization_of_reference<reference<Q, U>> : std::true_type {};
} // namespace detail
MP_UNITS_EXPORT_BEGIN
[[nodiscard]] consteval QuantitySpec auto get_quantity_spec(AssociatedUnit auto u);
@@ -67,7 +56,7 @@ template<typename Q, typename U>
* Satisfied by all specializations of @c reference.
*/
template<typename T>
concept Reference = AssociatedUnit<T> || detail::is_specialization_of_reference<T>::value;
concept Reference = AssociatedUnit<T> || is_specialization_of<T, reference>;
/**
* @brief A concept matching all references with provided quantity spec

View File

@@ -533,12 +533,6 @@ template<Unit T, typename... Expr>
return canonical_unit{num.mag / den.mag, num.reference_unit / den.reference_unit};
}
template<typename T>
constexpr bool is_specialization_of_derived_unit = false;
template<typename... Expr>
constexpr bool is_specialization_of_derived_unit<derived_unit<Expr...>> = true;
} // namespace detail
MP_UNITS_EXPORT_BEGIN
@@ -564,7 +558,7 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
return u;
else if constexpr (detail::is_specialization_of_scaled_unit<U>)
return scaled_unit<pow<Num, Den>(U::mag), decltype(pow<Num, Den>(U::reference_unit))>{};
else if constexpr (detail::is_specialization_of_derived_unit<U>)
else if constexpr (is_specialization_of<U, derived_unit>)
return detail::expr_pow<Num, Den, derived_unit, struct one, detail::type_list_of_unit_less>(u);
else if constexpr (Den == 1)
return derived_unit<power<U, Num>>{};