refactor: 💥 MagConstant concept renamed to detail::is_mag_constant variable trait

This commit is contained in:
Mateusz Pusz
2025-02-12 09:51:14 +01:00
parent 47cd2fffcc
commit 5963a2eb87
2 changed files with 9 additions and 9 deletions

View File

@ -52,7 +52,7 @@ import std;
namespace mp_units::detail { namespace mp_units::detail {
template<typename T> template<typename T>
concept MagArg = std::integral<T> || MagConstant<T>; concept MagArg = std::integral<T> || is_mag_constant<T>;
/** /**
* @brief Any type which can be used as a basis vector in a power_v. * @brief Any type which can be used as a basis vector in a power_v.
@ -89,7 +89,7 @@ template<typename T>
{ {
if constexpr (is_specialization_of_v<T, power_v>) if constexpr (is_specialization_of_v<T, power_v>)
return get_base_value(T::base); return get_base_value(T::base);
else if constexpr (MagConstant<T>) else if constexpr (is_mag_constant<T>)
return element._value_; return element._value_;
else else
return element; return element;
@ -559,7 +559,7 @@ template<auto M>
template<auto M> template<auto M>
[[nodiscard]] consteval auto remove_mag_constants(unit_magnitude<M> m) [[nodiscard]] consteval auto remove_mag_constants(unit_magnitude<M> m)
{ {
if constexpr (MagConstant<decltype(get_base(M))>) if constexpr (is_mag_constant<decltype(get_base(M))>)
return unit_magnitude<>{}; return unit_magnitude<>{};
else else
return m; return m;
@ -568,7 +568,7 @@ template<auto M>
template<auto M> template<auto M>
[[nodiscard]] consteval auto only_positive_mag_constants(unit_magnitude<M> m) [[nodiscard]] consteval auto only_positive_mag_constants(unit_magnitude<M> m)
{ {
if constexpr (MagConstant<decltype(get_base(M))> && get_exponent(M) >= 0) if constexpr (is_mag_constant<decltype(get_base(M))> && get_exponent(M) >= 0)
return m; return m;
else else
return unit_magnitude<>{}; return unit_magnitude<>{};
@ -577,7 +577,7 @@ template<auto M>
template<auto M> template<auto M>
[[nodiscard]] consteval auto only_negative_mag_constants(unit_magnitude<M> m) [[nodiscard]] consteval auto only_negative_mag_constants(unit_magnitude<M> m)
{ {
if constexpr (MagConstant<decltype(get_base(M))> && get_exponent(M) < 0) if constexpr (is_mag_constant<decltype(get_base(M))> && get_exponent(M) < 0)
return m; return m;
else else
return unit_magnitude<>{}; return unit_magnitude<>{};
@ -619,7 +619,7 @@ constexpr auto prime_factorization_v = prime_factorization<N>::value;
template<MagArg auto V> template<MagArg auto V>
[[nodiscard]] consteval UnitMagnitude auto make_magnitude() [[nodiscard]] consteval UnitMagnitude auto make_magnitude()
{ {
if constexpr (MagConstant<MP_UNITS_REMOVE_CONST(decltype(V))>) if constexpr (is_mag_constant<MP_UNITS_REMOVE_CONST(decltype(V))>)
return unit_magnitude<V>{}; return unit_magnitude<V>{};
else else
return prime_factorization_v<V>; return prime_factorization_v<V>;

View File

@ -46,14 +46,14 @@ MP_UNITS_EXPORT template<symbol_text Symbol, long double Value>
#endif #endif
struct mag_constant; struct mag_constant;
MP_UNITS_EXPORT template<typename T>
concept MagConstant = detail::SymbolicConstant<T> && is_derived_from_specialization_of_v<T, mag_constant>;
namespace detail { namespace detail {
template<auto... Ms> template<auto... Ms>
struct unit_magnitude; struct unit_magnitude;
template<typename T>
constexpr bool is_mag_constant = detail::SymbolicConstant<T> && is_derived_from_specialization_of_v<T, mag_constant>;
} }
/** /**