diff --git a/include/boost/core/default_allocator.hpp b/include/boost/core/default_allocator.hpp index c269b85..eadd293 100644 --- a/include/boost/core/default_allocator.hpp +++ b/include/boost/core/default_allocator.hpp @@ -10,6 +10,7 @@ Distributed under the Boost Software License, Version 1.0. #include #include +#include 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(0) / sizeof(T); +#endif } #if !defined(BOOST_NO_EXCEPTIONS)