Explicitly invoke the size_type specialization of max and min. This

avoids bugs where, when the allocator's size_type was smaller than int,
the multiplication or division would cause integral promotions and, with
two different integer types as arguments, deduction of the template
arguments would fail.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@136540 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Hunt 2011-07-29 23:31:58 +00:00
parent affd9e5d43
commit 110b8bf57e

View File

@ -794,7 +794,7 @@ template <class _Tp, class _Allocator>
typename vector<_Tp, _Allocator>::size_type
vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
{
return _VSTD::min(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2); // end() >= begin(), always
return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2); // end() >= begin(), always
}
// Precondition: __new_size > capacity()
@ -809,7 +809,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
const size_type __cap = capacity();
if (__cap >= __ms / 2)
return __ms;
return _VSTD::max(2*__cap, __new_size);
return _VSTD::max<size_type>(2*__cap, __new_size);
}
// Default constructs __n objects starting at __end_