mirror of
https://github.com/boostorg/core.git
synced 2025-07-30 04:47:24 +02:00
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 <boost/config.hpp>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
@ -59,7 +60,11 @@ struct default_allocator {
|
|||||||
BOOST_NOEXCEPT { }
|
BOOST_NOEXCEPT { }
|
||||||
|
|
||||||
BOOST_CONSTEXPR std::size_t max_size() const 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);
|
return ~static_cast<std::size_t>(0) / sizeof(T);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||||
|
Reference in New Issue
Block a user