Use custom placement new to support -fno-exceptions

This commit is contained in:
Ion Gaztañaga
2020-10-21 22:49:25 +02:00
parent 31d7f3875f
commit 6ca40b9e86
2 changed files with 6 additions and 4 deletions

View File

@@ -30,6 +30,7 @@
#include <boost/container/detail/iterator.hpp>
#include <boost/move/detail/iterator_to_raw_pointer.hpp>
#include <boost/container/detail/math_functions.hpp>
#include <boost/container/detail/placement_new.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/move/detail/to_raw_pointer.hpp>
#include <boost/container/detail/type_traits.hpp>
@@ -662,7 +663,7 @@ class private_adaptive_node_pool_impl_common
this->priv_deallocate_nodes(chain, max_free_blocks, real_num_node, num_subblocks, real_block_alignment);
throw_bad_alloc();
}
block_info_t &c_info = *new(mem_address)block_info_t();
block_info_t &c_info = *new(mem_address, boost_container_new_t())block_info_t();
mem_address += HdrSize;
this->priv_fill_chain_remaining_to_block(chain, target_elem_in_chain, c_info, mem_address, real_num_node, real_node_size);
const size_type free_nodes = c_info.free_nodes.size();
@@ -703,7 +704,7 @@ class private_adaptive_node_pool_impl_common
}
//First initialize header information on the last subblock
char *hdr_addr = mem_address + real_block_alignment*(num_subblocks-1);
block_info_t &c_info = *new(hdr_addr)block_info_t();
block_info_t &c_info = *new(hdr_addr, boost_container_new_t())block_info_t();
//Some structural checks
BOOST_ASSERT(static_cast<void*>(&static_cast<hdr_offset_holder&>(c_info).hdr_offset) ==
static_cast<void*>(&c_info)); (void)c_info;
@@ -711,7 +712,7 @@ class private_adaptive_node_pool_impl_common
; subblock < maxsubblock
; ++subblock, mem_address += real_block_alignment){
//Initialize header offset mark
new(mem_address) hdr_offset_holder(size_type(hdr_addr - mem_address));
new(mem_address, boost_container_new_t()) hdr_offset_holder(size_type(hdr_addr - mem_address));
const size_type elements_per_subblock = (subblock != (maxsubblock - 1)) ? elements_per_subblock_mid : elements_per_subblock_end;
this->priv_fill_chain_remaining_to_block
(chain, target_elem_in_chain, c_info, mem_address + HdrOffsetSize, elements_per_subblock, real_node_size);

View File

@@ -27,6 +27,7 @@
#include <boost/move/detail/to_raw_pointer.hpp>
#include <boost/container/detail/transform_iterator.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/placement_new.hpp>
// intrusive
#include <boost/intrusive/slist.hpp>
#include <boost/intrusive/pointer_traits.hpp>
@@ -152,7 +153,7 @@ class basic_multiallocation_chain
char_ptr prev_elem = elem;
elem += unit_bytes;
for(size_type i = 0; i != num_units-1; ++i, elem += unit_bytes){
::new (boost::movelib::to_raw_pointer(prev_elem)) void_pointer(elem);
::new (boost::movelib::to_raw_pointer(prev_elem), boost_container_new_t()) void_pointer(elem);
prev_elem = elem;
}
slist_impl_.incorporate_after(after_this, to_node_ptr(b), to_node_ptr(prev_elem), num_units);