mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 13:34:30 +02:00
Use new "data" member char array in aligned_storage::type for placement new, to avoid breaking strict aliasing.
This commit is contained in:
@@ -271,7 +271,7 @@ struct insert_emplace_proxy
|
||||
{
|
||||
BOOST_ASSERT(n ==1); (void)n;
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
|
||||
value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));
|
||||
value_type *vp = static_cast<value_type *>(static_cast<void *>(v.data));
|
||||
alloc_traits::construct(a, vp,
|
||||
::boost::forward<Args>(get<IdxPack>(this->args_))...);
|
||||
BOOST_TRY{
|
||||
@@ -382,7 +382,7 @@ struct insert_emplace_proxy_arg##N\
|
||||
BOOST_ASSERT(n == 1); (void)n;\
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
|
||||
BOOST_ASSERT((((size_type)(&v)) % alignment_of<value_type>::value) == 0);\
|
||||
value_type *vp = static_cast<value_type *>(static_cast<void *>(&v));\
|
||||
value_type *vp = static_cast<value_type *>(static_cast<void *>(v.data));\
|
||||
alloc_traits::construct(a, vp BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\
|
||||
BOOST_TRY{\
|
||||
*p = ::boost::move(*vp);\
|
||||
|
@@ -1008,7 +1008,7 @@ inline typename dtl::enable_if_c
|
||||
const std::size_t n_i_bytes = sizeof(value_type)*n_i;
|
||||
void *const large_ptr = static_cast<void*>(boost::movelib::iterator_to_raw_pointer(large_range_f));
|
||||
void *const short_ptr = static_cast<void*>(boost::movelib::iterator_to_raw_pointer(short_range_f));
|
||||
void *const stora_ptr = static_cast<void*>(boost::movelib::iterator_to_raw_pointer(storage));
|
||||
void *const stora_ptr = static_cast<void*>(boost::movelib::iterator_to_raw_pointer(storage.data));
|
||||
std::memcpy(stora_ptr, large_ptr, n_i_bytes);
|
||||
std::memcpy(large_ptr, short_ptr, n_i_bytes);
|
||||
std::memcpy(short_ptr, stora_ptr, n_i_bytes);
|
||||
@@ -1039,7 +1039,7 @@ inline typename dtl::enable_if_c
|
||||
std::size_t n_i_bytes = sizeof(value_type)*n_i;
|
||||
char *large_ptr = static_cast<char*>(static_cast<void*>(boost::movelib::iterator_to_raw_pointer(large_range_f)));
|
||||
char *short_ptr = static_cast<char*>(static_cast<void*>(boost::movelib::iterator_to_raw_pointer(short_range_f)));
|
||||
char *stora_ptr = static_cast<char*>(static_cast<void*>(&storage));
|
||||
char *stora_ptr = static_cast<char*>(static_cast<void*>(storage.data));
|
||||
|
||||
std::size_t szt_times = n_i_bytes/sizeof_storage;
|
||||
const std::size_t szt_rem = n_i_bytes%sizeof_storage;
|
||||
|
@@ -921,7 +921,7 @@ class flat_tree
|
||||
std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
|
||||
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);
|
||||
@@ -933,7 +933,7 @@ class flat_tree
|
||||
{
|
||||
//hint checked in insert_unique
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
|
||||
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);
|
||||
@@ -944,7 +944,7 @@ class flat_tree
|
||||
iterator emplace_equal(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
|
||||
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);
|
||||
@@ -956,7 +956,7 @@ class flat_tree
|
||||
{
|
||||
//hint checked in insert_equal
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
|
||||
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);
|
||||
@@ -993,7 +993,7 @@ class flat_tree
|
||||
std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
|
||||
stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);\
|
||||
@@ -1004,7 +1004,7 @@ class flat_tree
|
||||
iterator emplace_hint_unique(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
|
||||
stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);\
|
||||
@@ -1015,7 +1015,7 @@ class flat_tree
|
||||
iterator emplace_equal(BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
|
||||
stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);\
|
||||
@@ -1026,7 +1026,7 @@ class flat_tree
|
||||
iterator emplace_hint_equal(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
typename aligned_storage <sizeof(value_type), alignment_of<value_type>::value>::type v;\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(&v));\
|
||||
value_type &val = *static_cast<value_type *>(static_cast<void *>(v.data));\
|
||||
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
|
||||
stored_allocator_traits::construct(a, &val BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, val);\
|
||||
|
@@ -338,7 +338,7 @@ class small_vector_base
|
||||
pointer internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return boost::intrusive::pointer_traits<pointer>::pointer_to
|
||||
(*const_cast<T*>(static_cast<const T*>(static_cast<const void*>(&m_storage_start))));
|
||||
(*const_cast<T*>(static_cast<const T*>(static_cast<const void*>(m_storage_start.data))));
|
||||
}
|
||||
|
||||
typedef vector<T, small_vector_allocator<SecondaryAllocator> > base_type;
|
||||
|
@@ -51,10 +51,10 @@ class static_storage_allocator
|
||||
{ return *this; }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE T* internal_storage() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return const_cast<T*>(static_cast<const T*>(static_cast<const void*>(&storage))); }
|
||||
{ return const_cast<T*>(static_cast<const T*>(static_cast<const void*>(storage.data))); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE T* internal_storage() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return static_cast<T*>(static_cast<void*>(&storage)); }
|
||||
{ return static_cast<T*>(static_cast<void*>(storage.data)); }
|
||||
|
||||
static const std::size_t internal_capacity = N;
|
||||
|
||||
|
@@ -199,7 +199,7 @@ class basic_string_base
|
||||
{ return s; }
|
||||
|
||||
const long_t &long_repr() const
|
||||
{ return *static_cast<const long_t*>(static_cast<const void*>(&r)); }
|
||||
{ return *static_cast<const long_t*>(static_cast<const void*>(r.data)); }
|
||||
|
||||
short_t &short_repr()
|
||||
{ return s; }
|
||||
|
Reference in New Issue
Block a user