refactor: not needed remove_reference_t and remove_cvref_t removed

This commit is contained in:
Mateusz Pusz
2024-06-01 10:03:53 +02:00
parent b885f2b84e
commit e25364b3e0
8 changed files with 14 additions and 18 deletions

View File

@@ -41,7 +41,7 @@ void to_base_specialization_of_quantity(const volatile quantity<R, Rep>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_quantity = inline constexpr bool is_derived_from_specialization_of_quantity =
requires(std::remove_reference_t<T>* t) { to_base_specialization_of_quantity(t); }; requires(T* t) { to_base_specialization_of_quantity(t); };
} // namespace detail } // namespace detail

View File

@@ -915,12 +915,11 @@ template<typename From, typename To>
return extract_results{false}; return extract_results{false};
else if constexpr (from_exp > to_exp) else if constexpr (from_exp > to_exp)
return extract_results{true, pow<to_exp.num, to_exp.den>(from_factor), pow<to_exp.num, to_exp.den>(to_factor), return extract_results{true, pow<to_exp.num, to_exp.den>(from_factor), pow<to_exp.num, to_exp.den>(to_factor),
prepend_rest::first, prepend_rest::first, power_or_T<decltype(from_factor), from_exp - to_exp>{}};
power_or_T<std::remove_cvref_t<decltype(from_factor)>, from_exp - to_exp>{}};
else else
return extract_results{true, pow<from_exp.num, from_exp.den>(from_factor), return extract_results{true, pow<from_exp.num, from_exp.den>(from_factor),
pow<from_exp.num, from_exp.den>(to_factor), prepend_rest::second, pow<from_exp.num, from_exp.den>(to_factor), prepend_rest::second,
power_or_T<std::remove_cvref_t<decltype(to_factor)>, to_exp - from_exp>{}}; power_or_T<decltype(to_factor), to_exp - from_exp>{}};
} }
} }
@@ -934,7 +933,7 @@ template<process_entities Entities, auto Ext, TypeList NumFrom, TypeList DenFrom
if constexpr (Ext.prepend == prepend_rest::no) if constexpr (Ext.prepend == prepend_rest::no)
return min(res, are_ingredients_convertible(num_from, den_from, num_to, den_to)); return min(res, are_ingredients_convertible(num_from, den_from, num_to, den_to));
else { else {
using elem = std::remove_cvref_t<decltype(Ext.elem)>; using elem = decltype(Ext.elem);
if constexpr (Entities == process_entities::numerators) { if constexpr (Entities == process_entities::numerators) {
if constexpr (Ext.prepend == prepend_rest::first) if constexpr (Ext.prepend == prepend_rest::first)
return min(res, are_ingredients_convertible(type_list_push_front<NumFrom, elem>{}, den_from, num_to, den_to)); return min(res, are_ingredients_convertible(type_list_push_front<NumFrom, elem>{}, den_from, num_to, den_to));
@@ -959,7 +958,7 @@ template<process_entities Entities, auto Ext, TypeList NumFrom, TypeList DenFrom
if constexpr (Ext.prepend == prepend_rest::no) if constexpr (Ext.prepend == prepend_rest::no)
return are_ingredients_convertible(num_from, den_from, num_to, den_to); return are_ingredients_convertible(num_from, den_from, num_to, den_to);
else { else {
using elem = std::remove_cvref_t<decltype(Ext.elem)>; using elem = decltype(Ext.elem);
if constexpr (Entities == process_entities::from) { if constexpr (Entities == process_entities::from) {
if constexpr (Ext.prepend == prepend_rest::first) if constexpr (Ext.prepend == prepend_rest::first)
return are_ingredients_convertible(type_list_push_front<NumFrom, elem>{}, den_from, num_to, den_to); return are_ingredients_convertible(type_list_push_front<NumFrom, elem>{}, den_from, num_to, den_to);
@@ -1342,8 +1341,7 @@ template<QuantitySpec From, QuantitySpec To>
using enum specs_convertible_result; using enum specs_convertible_result;
return res == no ? no : yes; return res == no ? no : yes;
}; };
if constexpr ((NamedQuantitySpec<std::remove_cvref_t<decltype(from_kind)>> && if constexpr ((NamedQuantitySpec<decltype(from_kind)> && NamedQuantitySpec<decltype(to_kind)>) ||
NamedQuantitySpec<std::remove_cvref_t<decltype(to_kind)>>) ||
get_complexity(from_kind) == get_complexity(to_kind)) get_complexity(from_kind) == get_complexity(to_kind))
return convertible_impl(from_kind, to_kind); return convertible_impl(from_kind, to_kind);
else if constexpr (get_complexity(from_kind) > get_complexity(to_kind)) else if constexpr (get_complexity(from_kind) > get_complexity(to_kind))

View File

@@ -140,9 +140,8 @@ namespace detail {
template<auto To, auto From> template<auto To, auto From>
concept NestedQuantityKindSpecOf = concept NestedQuantityKindSpecOf =
QuantitySpec<decltype(From)> && QuantitySpec<decltype(To)> && QuantitySpec<decltype(From)> && QuantitySpec<decltype(To)> && get_kind(From) != get_kind(To) &&
get_kind(From) != get_kind(To) && std::derived_from<decltype(To), std::remove_const_t<decltype(get_kind(From)._quantity_spec_)>>;
std::derived_from<std::remove_cvref_t<decltype(To)>, std::remove_cvref_t<decltype(get_kind(From)._quantity_spec_)>>;
} }

View File

@@ -432,9 +432,9 @@ MP_UNITS_EXPORT_BEGIN
* 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.
*/ */
template<Magnitude M, Unit U> template<Magnitude M, Unit U>
[[nodiscard]] MP_UNITS_CONSTEVAL Unit auto operator*(M, const U u) [[nodiscard]] MP_UNITS_CONSTEVAL Unit auto operator*(M, U u)
{ {
if constexpr (std::is_same_v<M, std::remove_cvref_t<decltype(mp_units::mag<1>)>>) if constexpr (std::is_same_v<M, std::remove_const_t<decltype(mp_units::mag<1>)>>)
return u; return u;
else else
return scaled_unit<M{}, U>{}; return scaled_unit<M{}, U>{};
@@ -446,7 +446,7 @@ template<Magnitude M, Unit U>
* Returns the result of multiplication with an inverse unit. * Returns the result of multiplication with an inverse unit.
*/ */
template<Magnitude M, Unit U> template<Magnitude M, Unit U>
[[nodiscard]] MP_UNITS_CONSTEVAL Unit auto operator/(M mag, const U u) [[nodiscard]] MP_UNITS_CONSTEVAL Unit auto operator/(M mag, U u)
{ {
return mag * inverse(u); return mag * inverse(u);
} }

View File

@@ -82,7 +82,7 @@ static_assert(!std::convertible_to<min_impl<double>, quantity<si::metre, min_imp
// multiply syntax should work // multiply syntax should work
template<typename T, auto U> template<typename T, auto U>
concept creates_quantity = Unit<std::remove_cvref_t<decltype(U)>> && requires { T{} * U; }; concept creates_quantity = Unit<decltype(U)> && requires { T{} * U; };
static_assert(creates_quantity<min_impl<int>, si::metre>); static_assert(creates_quantity<min_impl<int>, si::metre>);
static_assert(creates_quantity<min_impl<double>, si::metre>); static_assert(creates_quantity<min_impl<double>, si::metre>);

View File

@@ -83,7 +83,7 @@ static_assert(Magnitude<decltype(mag<2>)>);
static_assert(Magnitude<mag_2_>); static_assert(Magnitude<mag_2_>);
// is_named_magnitude // is_named_magnitude
static_assert(!is_named_magnitude<std::remove_cvref_t<decltype(mag<2>)>>); static_assert(!is_named_magnitude<decltype(mag<2>)>);
static_assert(is_named_magnitude<mag_2_>); static_assert(is_named_magnitude<mag_2_>);
// power_v // power_v

View File

@@ -27,7 +27,7 @@
#include <type_traits> #include <type_traits>
template<auto V, typename T> template<auto V, typename T>
inline constexpr bool is_of_type = std::is_same_v<std::remove_cvref_t<decltype(V)>, T>; inline constexpr bool is_of_type = std::is_same_v<decltype(V), T>;
// NOLINTBEGIN(cppcoreguidelines-macro-usage) // NOLINTBEGIN(cppcoreguidelines-macro-usage)
#ifdef MP_UNITS_API_NO_CRTP #ifdef MP_UNITS_API_NO_CRTP

View File

@@ -240,7 +240,6 @@ static_assert(si::yotta<metre>.symbol == "Ym");
static_assert(si::ronna<metre>.symbol == "Rm"); static_assert(si::ronna<metre>.symbol == "Rm");
static_assert(si::quetta<metre>.symbol == "Qm"); static_assert(si::quetta<metre>.symbol == "Qm");
// scaled_unit // scaled_unit
constexpr auto m_1 = mag<1> * metre; constexpr auto m_1 = mag<1> * metre;
static_assert(is_of_type<m_1, metre_>); static_assert(is_of_type<m_1, metre_>);