Update computation of max_size

This commit is contained in:
Glen Fernandes
2019-04-25 11:49:36 -04:00
parent b5c178ef0b
commit 69f7b0c76b

View File

@ -10,6 +10,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#include <new>
#include <climits>
namespace boost {
@ -59,7 +60,11 @@ struct default_allocator {
BOOST_NOEXCEPT { }
BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT {
#if defined(PTRDIFF_MAX) && defined(SIZE_MAX) && (PTRDIFF_MAX < SIZE_MAX)
return PTRDIFF_MAX / sizeof(T);
#else
return ~static_cast<std::size_t>(0) / sizeof(T);
#endif
}
#if !defined(BOOST_NO_EXCEPTIONS)