diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 29f2c2afb3..81e476ab1f 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -949,21 +949,17 @@ _CONSTEXPR20 void _Destroy_range(_NoThrowFwdIt _First, const _NoThrowSentinel _L } template -_NODISCARD constexpr _Size_type _Convert_size(const size_t _Len) noexcept { +_NODISCARD constexpr _Size_type _Convert_size(const size_t _Len) noexcept(is_same_v<_Size_type, size_t>) { // convert size_t to _Size_type, avoiding truncation - if (_Len > (numeric_limits<_Size_type>::max) ()) { - _Xlength_error("size_t too long for _Size_type"); + if constexpr (!is_same_v<_Size_type, size_t>) { + if (_Len > (numeric_limits<_Size_type>::max) ()) { + _Xlength_error("size_t too long for _Size_type"); + } } return static_cast<_Size_type>(_Len); } -template <> -_NODISCARD constexpr size_t _Convert_size(const size_t _Len) noexcept { - // convert size_t to size_t, unchanged - return _Len; -} - template _CONSTEXPR20 void _Deallocate_plain(_Alloc& _Al, typename _Alloc::value_type* const _Ptr) noexcept { // deallocate a plain pointer using an allocator