From cf3d6d3c51bd702c8451a8c230b8914e325f8ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 6 Jan 2022 23:33:54 +0100 Subject: [PATCH] Fixes #199 ("Apply LWG issue 3471") --- doc/container.qbk | 1 + include/boost/container/pmr/memory_resource.hpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/container.qbk b/doc/container.qbk index af24e37..4e8da57 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -1342,6 +1342,7 @@ use [*Boost.Container]? There are several reasons for that: * The library now compiles without warnings with GCC's -Wcast-align=strict * Fixed bugs/issues: + * [@https://github.com/boostorg/container/issues/199 GitHub #199: ['"Apply LWG issue 3471 to memory_resource"]]. * [@https://github.com/boostorg/container/issues/206 GitHub #206: ['"operator-> on static_vector::iterator causes cast alignment warning"]]. [endsect] diff --git a/include/boost/container/pmr/memory_resource.hpp b/include/boost/container/pmr/memory_resource.hpp index 6f4f24c..e99fd02 100644 --- a/include/boost/container/pmr/memory_resource.hpp +++ b/include/boost/container/pmr/memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace boost { @@ -41,7 +42,11 @@ class memory_resource //! Effects: Equivalent to //! `return do_allocate(bytes, alignment);` void* allocate(std::size_t bytes, std::size_t alignment = max_align) - { return this->do_allocate(bytes, alignment); } + { + //Obtain a pointer to enough storage and initialize the lifetime + //of an array object of the given size in the address + return ::operator new(bytes, this->do_allocate(bytes, alignment), boost_container_new_t()); + } //! Effects: Equivalent to //! `return do_deallocate(bytes, alignment);`