From a43830544adfc7e3187c538f18b352af3702d247 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Fri, 1 Dec 2023 19:15:26 +0300 Subject: [PATCH] Removed forwarding resource and deleter when constructor may throw. 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. --- include/boost/scope/unique_resource.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/scope/unique_resource.hpp b/include/boost/scope/unique_resource.hpp index cda8185..706b44a 100644 --- a/include/boost/scope/unique_resource.hpp +++ b/include/boost/scope/unique_resource.hpp @@ -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); } }; @@ -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); } }; @@ -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 (...)