From 69f7b0c76b53ae05cd24f4bd856d0cdebe3815ef Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Thu, 25 Apr 2019 11:49:36 -0400 Subject: [PATCH] Update computation of max_size --- include/boost/core/default_allocator.hpp | 5 +++++ 1 file changed, 5 insertions(+) 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)