forked from boostorg/core
Update computation of max_size
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user