Fix some type punning warnings, avoiding forming a reference to non-constructed objects

This commit is contained in:
Ion Gaztañaga
2018-09-15 01:20:43 +02:00
parent 5ab5c7de63
commit 43c0d7a731

View File

@@ -921,11 +921,11 @@ class flat_tree
std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args) std::pair<iterator, bool> emplace_unique(BOOST_FWD_REF(Args)... args)
{ {
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; 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(); get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
value_destructor<stored_allocator_type, value_type> d(a, val); value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_unique(::boost::move(val)); return this->insert_unique(::boost::move(*pval));
} }
template <class... Args> template <class... Args>
@@ -933,22 +933,22 @@ class flat_tree
{ {
//hint checked in insert_unique //hint checked in insert_unique
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; 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(); get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
value_destructor<stored_allocator_type, value_type> d(a, val); value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_unique(hint, ::boost::move(val)); return this->insert_unique(hint, ::boost::move(*pval));
} }
template <class... Args> template <class... Args>
iterator emplace_equal(BOOST_FWD_REF(Args)... args) iterator emplace_equal(BOOST_FWD_REF(Args)... args)
{ {
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; 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(); get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
value_destructor<stored_allocator_type, value_type> d(a, val); value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_equal(::boost::move(val)); return this->insert_equal(::boost::move(*pval));
} }
template <class... Args> template <class... Args>
@@ -956,11 +956,11 @@ class flat_tree
{ {
//hint checked in insert_equal //hint checked in insert_equal
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v; 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(); get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, &val, ::boost::forward<Args>(args)... ); stored_allocator_traits::construct(a, pval, ::boost::forward<Args>(args)... );
value_destructor<stored_allocator_type, value_type> d(a, val); value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_equal(hint, ::boost::move(val)); return this->insert_equal(hint, ::boost::move(*pval));
} }
template <class KeyType, class... Args> template <class KeyType, class... Args>
@@ -993,44 +993,44 @@ class flat_tree
std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\ std::pair<iterator, bool> emplace_unique(BOOST_MOVE_UREF##N)\
{\ {\
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ 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();\ 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);\ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_destructor<stored_allocator_type, value_type> d(a, val);\ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_unique(::boost::move(val));\ return this->insert_unique(::boost::move(*pval));\
}\ }\
\ \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ 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)\ 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;\ 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();\ 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);\ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_destructor<stored_allocator_type, value_type> d(a, val);\ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_unique(hint, ::boost::move(val));\ return this->insert_unique(hint, ::boost::move(*pval));\
}\ }\
\ \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace_equal(BOOST_MOVE_UREF##N)\ iterator emplace_equal(BOOST_MOVE_UREF##N)\
{\ {\
typename aligned_storage<sizeof(value_type), alignment_of<value_type>::value>::type v;\ 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();\ 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);\ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_destructor<stored_allocator_type, value_type> d(a, val);\ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_equal(::boost::move(val));\ return this->insert_equal(::boost::move(*pval));\
}\ }\
\ \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ 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)\ 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;\ 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();\ 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);\ stored_allocator_traits::construct(a, pval BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_destructor<stored_allocator_type, value_type> d(a, val);\ value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_equal(hint, ::boost::move(val));\ return this->insert_equal(hint, ::boost::move(*pval));\
}\ }\
template <class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\ template <class KeyType BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool>\ BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool>\