Fixes #210: ("Use sized delete in boost::container::new_allocator...")

This commit is contained in:
Ion Gaztañaga
2022-07-16 20:55:42 +02:00
parent 0d5068a0cc
commit b8c59d595c
3 changed files with 12 additions and 2 deletions

View File

@ -1342,6 +1342,7 @@ use [*Boost.Container]? There are several reasons for that:
* Fixed bugs/issues:
* [@https://github.com/boostorg/container/issues/209 GitHub #209: ['"Some boost warnings with my R package (Wclass-memaccess warnings with std::pair)"]].
* [@https://github.com/boostorg/container/issues/210 GitHub #210: ['"Use sized delete in boost::container::new_allocator if __cpp_sized_deallocation is defined"]].
* [@https://github.com/boostorg/container/issues/221 GitHub #218: ['"small_vector static capacity is too small when not a multiple of 8 bytes"]].
* [@https://github.com/boostorg/container/issues/221 GitHub #221: ['"flat_set and friends should offer a const sequence_type& sequence() const method (...)"]].
* [@https://github.com/boostorg/container/pull/222 GitHub #222: ['"Fix incomplete type error when using list with pair"]].

View File

@ -18,6 +18,8 @@
# pragma once
#endif
#include <cstddef>
struct boost_container_new_t{};
//avoid including <new>

View File

@ -162,8 +162,15 @@ class new_allocator
//!Deallocates previously allocated memory.
//!Never throws
void deallocate(pointer ptr, size_type) BOOST_NOEXCEPT_OR_NOTHROW
{ ::operator delete((void*)ptr); }
void deallocate(pointer ptr, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
(void)n;
# if __cpp_sized_deallocation
::operator delete((void*)ptr, n * sizeof(T));
#else
::operator delete((void*)ptr);
# endif
}
//!Returns the maximum number of elements that could be allocated.
//!Never throws