1
0
forked from boostorg/core

Add default_allocator allocate hint overload in C++03 mode

This commit is contained in:
Glen Fernandes
2021-12-04 14:41:23 -05:00
parent 8985ce604e
commit febc195093
3 changed files with 26 additions and 0 deletions

View File

@ -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<class U, class V>

View File

@ -211,6 +211,7 @@ run default_allocator_test.cpp
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
run default_allocator_allocate_hint_test.cpp ;
run noinit_adaptor_test.cpp ;
run alloc_construct_test.cpp ;

View File

@ -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 <boost/core/default_allocator.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
boost::default_allocator<int> a;
int* p = boost::allocator_allocate(a, 1, 0);
BOOST_TEST(p != 0);
a.deallocate(p, 1);
return boost::report_errors();
}