Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions stl/inc/xmemory
Original file line number Diff line number Diff line change
Expand Up @@ -949,21 +949,17 @@ _CONSTEXPR20 void _Destroy_range(_NoThrowFwdIt _First, const _NoThrowSentinel _L
}

template <class _Size_type>
_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<size_t>(const size_t _Len) noexcept {
// convert size_t to size_t, unchanged
return _Len;
}

template <class _Alloc>
_CONSTEXPR20 void _Deallocate_plain(_Alloc& _Al, typename _Alloc::value_type* const _Ptr) noexcept {
// deallocate a plain pointer using an allocator
Expand Down