Skip to content

Commit

Permalink
Removed forwarding resource and deleter when constructor may throw.
Browse files Browse the repository at this point in the history
When resource_holder and deleter_holder are constructed, and resource/deleter
constructor may throw, remove forwarding the source resource/deleter to
the constructor. Forwarding there has no effect anyway, as the unique_resource
constructor already ensures the corresponding argument is passed as
an lvalue reference by using move_or_copy_construct_ref.
  • Loading branch information
Lastique committed Dec 1, 2023
1 parent 969584e commit a438305
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/boost/scope/unique_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ class resource_holder :

template< typename R, typename D >
explicit resource_holder(R&& res, D&& del, bool allocated, std::false_type) try :
resource_base(static_cast< R&& >(res))
resource_base(res)
{
}
catch (...)
{
if (allocated)
del(static_cast< R&& >(res));
del(res);
}
};

Expand Down Expand Up @@ -280,13 +280,13 @@ class resource_holder< Resource, Traits, true > :

template< typename R, typename D >
explicit resource_holder(R&& res, D&& del, bool allocated, std::false_type) try :
resource_base(static_cast< R&& >(res))
resource_base(res)
{
}
catch (...)
{
if (allocated)
del(static_cast< R&& >(res));
del(res);
}
};

Expand Down Expand Up @@ -357,7 +357,7 @@ class deleter_holder :

template< typename D >
explicit deleter_holder(D&& del, resource_type& res, bool allocated, std::false_type) try :
deleter_base(static_cast< D&& >(del))
deleter_base(del)
{
}
catch (...)
Expand Down

0 comments on commit a438305

Please sign in to comment.