mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 13:34:30 +02:00
Fix some type punning warnings, avoiding forming a reference to non-constructed objects
This commit is contained in:
@@ -921,11 +921,11 @@ 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.data));
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);
|
||||
return this->insert_unique(::boost::move(val));
|
||||
stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);
|
||||
return this->insert_unique(::boost::move(*pval));
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
@@ -933,22 +933,22 @@ 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.data));
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);
|
||||
return this->insert_unique(hint, ::boost::move(val));
|
||||
stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);
|
||||
return this->insert_unique(hint, ::boost::move(*pval));
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
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.data));
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);
|
||||
return this->insert_equal(::boost::move(val));
|
||||
stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);
|
||||
return this->insert_equal(::boost::move(*pval));
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
@@ -956,11 +956,11 @@ 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.data));
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);
|
||||
return this->insert_equal(hint, ::boost::move(val));
|
||||
stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);
|
||||
return this->insert_equal(hint, ::boost::move(*pval));
|
||||
}
|
||||
|
||||
template <class KeyType, class... Args>
|
||||
@@ -993,44 +993,44 @@ 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.data));\
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);\
|
||||
return this->insert_unique(::boost::move(val));\
|
||||
stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
|
||||
return this->insert_unique(::boost::move(*pval));\
|
||||
}\
|
||||
\
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
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.data));\
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);\
|
||||
return this->insert_unique(hint, ::boost::move(val));\
|
||||
stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
|
||||
return this->insert_unique(hint, ::boost::move(*pval));\
|
||||
}\
|
||||
\
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
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.data));\
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);\
|
||||
return this->insert_equal(::boost::move(val));\
|
||||
stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
|
||||
return this->insert_equal(::boost::move(*pval));\
|
||||
}\
|
||||
\
|
||||
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
|
||||
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.data));\
|
||||
value_type *pval = reinterpret_cast<value_type *>(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);\
|
||||
return this->insert_equal(hint, ::boost::move(val));\
|
||||
stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
|
||||
return this->insert_equal(hint, ::boost::move(*pval));\
|
||||
}\
|
||||
template <class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool>\
|
||||
|
Reference in New Issue
Block a user