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:
Mateusz Pusz
2023-06-17 06:44:20 +03:00
parent 6db8012513
commit faa4c203aa
2 changed files with 14 additions and 11 deletions

View File

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

View File

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