forked from boostorg/core
Add default_allocator allocate hint overload in C++03 mode
This commit is contained in:
@ -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>
|
||||
|
@ -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 ;
|
||||
|
19
test/default_allocator_allocate_hint_test.cpp
Normal file
19
test/default_allocator_allocate_hint_test.cpp
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user