Clean force_ptr usage and use launder_cast

This commit is contained in:
Ion Gaztañaga committed 2024-04-15 12:51:15 +02:00
1 parent 56cc38f761
commit 978bbb113a
17 files changed
+98 -75

No files matched your search

@@ -39,6 +39,7 @@
#include <boost/move/utility_core.hpp>
#include <boost/move/detail/force_ptr.hpp>
#include <boost/move/detail/launder.hpp>
// other
#include <boost/assert.hpp>
@@ -138,8 +139,8 @@ struct insert_value_initialized_n_proxy
while (n){
--n;
storage_t v;
alloc_traits::construct(a, move_detail::force_ptr<value_type *>(&v));
value_type *vp = move_detail::force_ptr<value_type *>(&v);
alloc_traits::construct(a, (value_type*)&v);
value_type *vp = move_detail::launder_cast<value_type *>(&v);
value_destructor<Allocator> on_exit(a, *vp); (void)on_exit;
*p = ::boost::move(*vp);
++p;
@@ -165,8 +166,8 @@ struct insert_default_initialized_n_proxy
while (n){
--n;
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
alloc_traits::construct(a, move_detail::force_ptr<value_type *>(&v), default_init);
value_type *vp = move_detail::force_ptr<value_type *>(&v);
alloc_traits::construct(a, (value_type*)&v, default_init);
value_type *vp = move_detail::launder_cast<value_type *>(&v);
value_destructor<Allocator> on_exit(a, *vp); (void)on_exit;
*p = ::boost::move(*vp);
++p;
@@ -312,8 +313,8 @@ struct insert_emplace_proxy
{
BOOST_ASSERT(n ==1); (void)n;
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
alloc_traits::construct(a, move_detail::force_ptr<value_type *>(&v), ::boost::forward<Args>(get<IdxPack>(this->args_))...);
value_type *vp = move_detail::force_ptr<value_type *>(&v);
alloc_traits::construct(a, (value_type*)&v, ::boost::forward<Args>(get<IdxPack>(this->args_))...);
value_type *vp = move_detail::launder_cast<value_type *>(&v);
BOOST_CONTAINER_TRY{
*p = ::boost::move(*vp);
}
@@ -435,8 +436,8 @@ struct insert_emplace_proxy_arg##N\
{\
BOOST_ASSERT(n == 1); (void)n;\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\
alloc_traits::construct(a, move_detail::force_ptr<value_type *>(&v) BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\
value_type *vp = move_detail::force_ptr<value_type *>(&v);\
alloc_traits::construct(a, (value_type*)&v BOOST_MOVE_I##N BOOST_MOVE_MFWD##N);\
value_type *vp = move_detail::launder_cast<value_type *>(&v);\
BOOST_CONTAINER_TRY{\
*p = ::boost::move(*vp);\
}\
+17 -16
View File
@@ -48,6 +48,7 @@
#include <boost/move/adl_move_swap.hpp>
#include <boost/move/detail/iterator_to_raw_pointer.hpp>
#include <boost/move/detail/force_ptr.hpp>
#include <boost/move/detail/launder.hpp>
#include <boost/move/algo/adaptive_sort.hpp>
#include <boost/move/algo/detail/pdqsort.hpp>
@@ -975,8 +976,8 @@ class flat_tree
{
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::force_ptr<value_type *>(&v);
stored_allocator_traits::construct(a, (value_type *)(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::launder_cast<value_type *>(&v);
value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_unique(::boost::move(*pval));
}
@@ -987,8 +988,8 @@ class flat_tree
//hint checked in insert_unique
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::force_ptr<value_type *>(&v);
stored_allocator_traits::construct(a, (value_type*)(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::launder_cast<value_type *>(&v);
value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_unique(hint, ::boost::move(*pval));
}
@@ -998,8 +999,8 @@ class flat_tree
{
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::force_ptr<value_type *>(&v);
stored_allocator_traits::construct(a, (value_type*)(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::launder_cast<value_type *>(&v);
value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_equal(::boost::move(*pval));
}
@@ -1010,8 +1011,8 @@ class flat_tree
//hint checked in insert_equal
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::force_ptr<value_type *>(&v);
stored_allocator_traits::construct(a, (value_type*)(&v), ::boost::forward<Args>(args)... );
value_type *pval = move_detail::launder_cast<value_type *>(&v);
value_destructor<stored_allocator_type, value_type> d(a, *pval);
return this->insert_equal(hint, ::boost::move(*pval));
}
@@ -1044,8 +1045,8 @@ class flat_tree
{\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::force_ptr<value_type *>(&v);\
stored_allocator_traits::construct(a, (value_type *)(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::launder_cast<value_type *>(&v);\
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_unique(::boost::move(*pval));\
}\
@@ -1055,8 +1056,8 @@ class flat_tree
{\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::force_ptr<value_type *>(&v);\
stored_allocator_traits::construct(a, (value_type *)(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::launder_cast<value_type *>(&v);\
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_unique(hint, ::boost::move(*pval));\
}\
@@ -1066,8 +1067,8 @@ class flat_tree
{\
typename dtl::aligned_storage<sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::force_ptr<value_type *>(&v);\
stored_allocator_traits::construct(a, (value_type *)(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::launder_cast<value_type *>(&v);\
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_equal(::boost::move(*pval));\
}\
@@ -1077,8 +1078,8 @@ class flat_tree
{\
typename dtl::aligned_storage <sizeof(value_type), dtl::alignment_of<value_type>::value>::type v;\
get_stored_allocator_noconst_return_t a = this->get_stored_allocator();\
stored_allocator_traits::construct(a, move_detail::force_ptr<value_type *>(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::force_ptr<value_type *>(&v);\
stored_allocator_traits::construct(a, (value_type *)(&v) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
value_type *pval = move_detail::launder_cast<value_type *>(&v);\
value_destructor<stored_allocator_type, value_type> d(a, *pval);\
return this->insert_equal(hint, ::boost::move(*pval));\
}\
@@ -31,6 +31,7 @@
#include <boost/container/detail/construct_in_place.hpp>
#include <boost/container/detail/destroyers.hpp>
#include <boost/move/detail/iterator_to_raw_pointer.hpp>
#include <boost/move/detail/launder.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/placement_new.hpp>
#include <boost/move/detail/to_raw_pointer.hpp>
@@ -119,16 +120,16 @@ struct base_node
}
inline T &get_data()
{ return *move_detail::force_ptr<T*>(this->m_storage.data); }
{ return *move_detail::force_ptr<T*>(&this->m_storage); }
inline const T &get_data() const
{ return *move_detail::force_ptr<const T*>(this->m_storage.data); }
{ return *move_detail::launder_cast<const T*>(&this->m_storage); }
inline internal_type &get_real_data()
{ return *move_detail::force_ptr<internal_type*>(this->m_storage.data); }
{ return *move_detail::launder_cast<internal_type*>(&this->m_storage); }
inline const internal_type &get_real_data() const
{ return *move_detail::force_ptr<const internal_type*>(this->m_storage.data); }
{ return *move_detail::launder_cast<const internal_type*>(&this->m_storage); }
#if defined(BOOST_CONTAINER_DISABLE_ALIASING_WARNING)
#pragma GCC diagnostic pop
-1
View File
@@ -52,7 +52,6 @@
#include <boost/move/detail/fwd_macros.hpp>
#endif
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/detail/force_ptr.hpp>