diff --git a/include/boost/core/default_allocator.hpp b/include/boost/core/default_allocator.hpp index a366f62..554e738 100644 --- a/include/boost/core/default_allocator.hpp +++ b/include/boost/core/default_allocator.hpp @@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0. #define BOOST_CORE_DEFAULT_ALLOCATOR_HPP #include -#include #include #if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000 @@ -82,10 +81,7 @@ struct default_allocator { BOOST_NOEXCEPT { } BOOST_CONSTEXPR std::size_t max_size() const BOOST_NOEXCEPT { - return std::numeric_limits::max() - < std::numeric_limits::max() / sizeof(T) - ? std::numeric_limits::max() - : std::numeric_limits::max() / sizeof(T); + return static_cast(-1) / (2 < sizeof(T) ? sizeof(T) : 2); } #if !defined(BOOST_NO_EXCEPTIONS) @@ -125,6 +121,7 @@ struct default_allocator { template void destroy(U* p) { p->~U(); + (void)p; } #endif }; diff --git a/test/default_allocator_test.cpp b/test/default_allocator_test.cpp index e921747..041c52a 100644 --- a/test/default_allocator_test.cpp +++ b/test/default_allocator_test.cpp @@ -173,20 +173,11 @@ void test_construct_other() (void)a5; } -#if defined(PTRDIFF_MAX) && defined(SIZE_MAX) template std::size_t max_size() { - return PTRDIFF_MAX < SIZE_MAX / sizeof(T) - ? PTRDIFF_MAX : SIZE_MAX / sizeof(T); + return static_cast(-1) / (2 < sizeof(T) ? sizeof(T) : 2); } -#else -template -std::size_t max_size() -{ - return ~static_cast(0) / sizeof(T); -} -#endif void test_max_size() {