diff --git a/stl/inc/utility b/stl/inc/utility index 070899fb3fa..49acc0badd9 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -840,7 +840,7 @@ _NODISCARD constexpr bool _Cmp_greater_equal(const _Ty1 _Left, const _Ty2 _Right template _NODISCARD constexpr _Ty _Min_limit() noexcept { // same as (numeric_limits<_Ty>::min)(), less throughput cost - _STL_INTERNAL_STATIC_ASSERT(_Is_standard_integer<_Ty>); // doesn't attempt to handle all types + _STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types if constexpr (is_signed_v<_Ty>) { constexpr auto _Unsigned_max = static_cast>(-1); return static_cast<_Ty>((_Unsigned_max >> 1) + 1); // well-defined, N4950 [conv.integral]/3 @@ -851,7 +851,7 @@ _NODISCARD constexpr _Ty _Min_limit() noexcept { // same as (numeric_limits<_Ty> template _NODISCARD constexpr _Ty _Max_limit() noexcept { // same as (numeric_limits<_Ty>::max)(), less throughput cost - _STL_INTERNAL_STATIC_ASSERT(_Is_standard_integer<_Ty>); // doesn't attempt to handle all types + _STL_INTERNAL_STATIC_ASSERT(is_integral_v<_Ty>); // doesn't attempt to handle all types if constexpr (is_signed_v<_Ty>) { constexpr auto _Unsigned_max = static_cast>(-1); return static_cast<_Ty>(_Unsigned_max >> 1); diff --git a/stl/inc/xutility b/stl/inc/xutility index 0fc9b352a0c..a7bc1079bf3 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -5938,9 +5938,8 @@ _NODISCARD constexpr bool _Could_compare_equal_to_value_type(const _Ty& _Val) { if constexpr (is_same_v<_Elem, bool>) { return _Val == true || _Val == false; } else if constexpr (is_signed_v<_Elem>) { - // use instead of numeric_limits::min/max; avoid dependency - constexpr _Elem _Min = static_cast<_Elem>(_Elem{1} << (sizeof(_Elem) * CHAR_BIT - 1)); - constexpr _Elem _Max = static_cast<_Elem>(~_Min); + constexpr _Elem _Min = _STD _Min_limit<_Elem>(); + constexpr _Elem _Max = _STD _Max_limit<_Elem>(); if constexpr (is_signed_v<_Ty>) { // signed _Elem, signed _Ty @@ -5956,7 +5955,7 @@ _NODISCARD constexpr bool _Could_compare_equal_to_value_type(const _Ty& _Val) { } } } else { - constexpr _Elem _Max = static_cast<_Elem>(~_Elem{0}); + constexpr _Elem _Max = _STD _Max_limit<_Elem>(); if constexpr (is_unsigned_v<_Ty>) { // unsigned _Elem, unsigned _Ty