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.
llvm-svn: 136540
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 8324378195dd6cddad509b72e3c5ea155b4d9ec3
diff --git a/include/vector b/include/vector
index 2aebf5c..8d9b421 100644
--- a/include/vector
+++ b/include/vector
@@ -794,7 +794,7 @@
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 @@
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_