mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 10:57:16 +02:00
fix: treat_as_floating_point
and Scalable
fixed for the case where the type has both value_type
and element_type
This commit is contained in:
@ -66,11 +66,12 @@ concept CastableNumber = CommonTypeWith<T, std::intmax_t> && ScalableNumber<std:
|
||||
|
||||
// TODO Fix it according to sudo_cast implementation
|
||||
template<typename T>
|
||||
concept Scalable = CastableNumber<T> ||
|
||||
(requires { typename T::value_type; } && CastableNumber<typename T::value_type> &&
|
||||
ScalableNumber<T, std::common_type_t<typename T::value_type, std::intmax_t>>) ||
|
||||
(requires { typename T::element_type; } && CastableNumber<typename T::element_type> &&
|
||||
ScalableNumber<T, std::common_type_t<typename T::element_type, std::intmax_t>>);
|
||||
concept Scalable =
|
||||
CastableNumber<T> ||
|
||||
(requires { typename T::value_type; } && CastableNumber<typename T::value_type> &&
|
||||
ScalableNumber<T, std::common_type_t<typename T::value_type, std::intmax_t>>) ||
|
||||
(requires { typename T::element_type; } && CastableNumber<std::remove_reference_t<typename T::element_type>> &&
|
||||
ScalableNumber<T, std::common_type_t<std::remove_reference_t<typename T::element_type>, std::intmax_t>>);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
@ -42,12 +42,14 @@ template<typename Rep>
|
||||
inline constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>;
|
||||
|
||||
template<typename Rep>
|
||||
requires requires { typename Rep::value_type; }
|
||||
inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<typename Rep::value_type>;
|
||||
|
||||
template<typename Rep>
|
||||
requires requires { typename Rep::element_type; }
|
||||
inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<typename Rep::element_type>;
|
||||
requires requires { typename Rep::value_type; } || requires { typename Rep::element_type; }
|
||||
inline constexpr bool treat_as_floating_point<Rep> = requires {
|
||||
typename Rep::value_type;
|
||||
requires treat_as_floating_point<typename Rep::value_type>;
|
||||
} || requires {
|
||||
typename Rep::element_type;
|
||||
requires treat_as_floating_point<std::remove_reference_t<typename Rep::element_type>>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Specifies a type to have a scalar character
|
||||
|
Reference in New Issue
Block a user