Skip to content

Commit

Permalink
replace placement_destroy usage with a simple range destruction helpe…
Browse files Browse the repository at this point in the history
…r function.
  • Loading branch information
igaztanaga committed Sep 14, 2024
1 parent 09f5aa6 commit d655964
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions include/boost/interprocess/detail/named_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,18 @@ namespace interprocess {
namespace ipcdetail {

template<class T>
struct placement_destroy
inline void named_construct_placement_destroy(void *mem, std::size_t num)
{
placement_destroy()
{}

virtual void destroy_n(void *mem, std::size_t num)
{
T* memory = static_cast<T*>(mem);
for(std::size_t destroyed = 0; destroyed < num; ++destroyed)
(memory++)->~T();
}

private:
void destroy(void *mem)
{ static_cast<T*>(mem)->~T(); }
T* memory = static_cast<T*>(mem); \
for(std::size_t destroyed = 0; destroyed < num; ++destroyed)
(memory++)->~T();
};


#ifdef BOOST_INTERPROCESS_PERFECT_FORWARDING

template<class T, bool is_iterator, class ...Args>
struct CtorArgN : public placement_destroy<T>
struct CtorArgN
{
typedef T object_type;
typedef bool_<is_iterator> IsIterator;
Expand Down Expand Up @@ -94,7 +84,7 @@ struct CtorArgN : public placement_destroy<T>
}
}
BOOST_INTERPROCESS_CATCH(...) {
this->placement_destroy<T>::destroy_n(mem, constructed);
named_construct_placement_destroy<T>(mem, constructed);
BOOST_INTERPROCESS_RETHROW
} BOOST_INTERPROCESS_CATCH_END
}
Expand Down Expand Up @@ -165,7 +155,7 @@ class named_proxy
#define BOOST_INTERPROCESS_NAMED_PROXY_CTORARGN(N)\
\
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
struct CtorArg##N : placement_destroy<T>\
struct CtorArg##N\
{\
typedef T object_type;\
typedef CtorArg##N self_t;\
Expand All @@ -183,7 +173,7 @@ struct CtorArg##N : placement_destroy<T>\
}\
}\
BOOST_INTERPROCESS_CATCH(...) {\
this->placement_destroy<T>::destroy_n(mem, constructed);\
named_construct_placement_destroy<T>(mem, constructed);\
BOOST_INTERPROCESS_RETHROW\
} BOOST_INTERPROCESS_CATCH_END\
}\
Expand All @@ -198,7 +188,7 @@ BOOST_MOVE_ITERATE_0TO9(BOOST_INTERPROCESS_NAMED_PROXY_CTORARGN)
#define BOOST_INTERPROCESS_NAMED_PROXY_CTORITN(N)\
\
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
struct CtorIt##N : public placement_destroy<T>\
struct CtorIt##N\
{\
typedef T object_type;\
typedef CtorIt##N self_t;\
Expand All @@ -222,7 +212,7 @@ struct CtorIt##N : public placement_destroy<T>\
}\
}\
BOOST_INTERPROCESS_CATCH(...) {\
this->placement_destroy<T>::destroy_n(mem, constructed);\
named_construct_placement_destroy<T>(mem, constructed);\
BOOST_INTERPROCESS_RETHROW\
} BOOST_INTERPROCESS_CATCH_END\
}\
Expand Down

0 comments on commit d655964

Please sign in to comment.