Add overaligned type support for global pmr: implement operator_new_raw_allocate/operator_delete_raw_deallocate and use them in new_delete_resource_imp

This commit is contained in:
Ion Gaztañaga
2025-12-23 11:02:38 +01:00
parent ce530f5fbe
commit e4fcf4b862
2 changed files with 34 additions and 18 deletions

View File

@@ -14,6 +14,7 @@
#include <boost/container/throw_exception.hpp>
#include <boost/container/detail/dlmalloc.hpp> //For global lock
#include <boost/container/detail/singleton.hpp>
#include <boost/container/detail/operator_new_helpers.hpp>
#include <cstddef>
#include <new>
@@ -31,10 +32,10 @@ class new_delete_resource_imp
{}
void* do_allocate(std::size_t bytes, std::size_t alignment) BOOST_OVERRIDE
{ (void)bytes; (void)alignment; return new char[bytes]; }
{ return boost::container::dtl::operator_new_raw_allocate(bytes, alignment); }
void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) BOOST_OVERRIDE
{ (void)bytes; (void)alignment; delete[]((char*)p); }
{ return boost::container::dtl::operator_delete_raw_deallocate(p, bytes, alignment); }
bool do_is_equal(const memory_resource& other) const BOOST_NOEXCEPT BOOST_OVERRIDE
{ return &other == this; }