From febc1950935cb85f66fc6ed276016c667a333552 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sat, 4 Dec 2021 14:41:23 -0500 Subject: [PATCH] Add default_allocator allocate hint overload in C++03 mode --- include/boost/core/default_allocator.hpp | 6 ++++++ test/Jamfile.v2 | 1 + test/default_allocator_allocate_hint_test.cpp | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 test/default_allocator_allocate_hint_test.cpp diff --git a/include/boost/core/default_allocator.hpp b/include/boost/core/default_allocator.hpp index 9e466ca..ba8540b 100644 --- a/include/boost/core/default_allocator.hpp +++ b/include/boost/core/default_allocator.hpp @@ -108,6 +108,12 @@ struct default_allocator { } #endif +#if defined(BOOST_NO_CXX11_ALLOCATOR) + T* allocate(std::size_t n, const void*) { + return allocate(n); + } +#endif + #if (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000) || \ defined(BOOST_NO_CXX11_ALLOCATOR) template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0518bdc..58d46f5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -211,6 +211,7 @@ run default_allocator_test.cpp msvc:on gcc:on clang:on ; +run default_allocator_allocate_hint_test.cpp ; run noinit_adaptor_test.cpp ; run alloc_construct_test.cpp ; diff --git a/test/default_allocator_allocate_hint_test.cpp b/test/default_allocator_allocate_hint_test.cpp new file mode 100644 index 0000000..fed2c90 --- /dev/null +++ b/test/default_allocator_allocate_hint_test.cpp @@ -0,0 +1,19 @@ +/* +Copyright 2021 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include + +int main() +{ + boost::default_allocator a; + int* p = boost::allocator_allocate(a, 1, 0); + BOOST_TEST(p != 0); + a.deallocate(p, 1); + return boost::report_errors(); +}