Replace usage of rote try-catch with corresponding Boost versions

This commit is contained in:
Christian Mazakas
2023-01-31 10:32:06 -08:00
parent 16099478db
commit a46220986f
2 changed files with 15 additions and 16 deletions

View File

@ -86,31 +86,26 @@ namespace boost {
template <class A>
static void construct(A& al, element_type* p, element_type const& copy)
{
p->p = boost::to_address(boost::allocator_allocate(al, 1));
try {
boost::allocator_construct(al, p->p, *copy.p);
} catch (...) {
boost::allocator_deallocate(al,
boost::pointer_traits<
typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
1);
throw;
}
construct(al, p, *copy.p);
}
template <class A, class... Args>
static void construct(A& al, element_type* p, Args&&... args)
{
p->p = boost::to_address(boost::allocator_allocate(al, 1));
try {
BOOST_TRY
{
boost::allocator_construct(al, p->p, std::forward<Args>(args)...);
} catch (...) {
}
BOOST_CATCH(...)
{
boost::allocator_deallocate(al,
boost::pointer_traits<
typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
1);
throw;
BOOST_RETHROW
}
BOOST_CATCH_END
}
template <class A> static void destroy(A& al, element_type* p) noexcept

View File

@ -76,15 +76,19 @@ namespace boost {
static void construct(A& al, element_type* p, Args&&... args)
{
p->p = boost::to_address(boost::allocator_allocate(al, 1));
try {
BOOST_TRY
{
boost::allocator_construct(al, p->p, std::forward<Args>(args)...);
} catch (...) {
}
BOOST_CATCH(...)
{
boost::allocator_deallocate(al,
boost::pointer_traits<
typename boost::allocator_pointer<A>::type>::pointer_to(*p->p),
1);
throw;
BOOST_RETHROW
}
BOOST_CATCH_END
}
template <class A> static void destroy(A& al, element_type* p) noexcept