return unique_resource<std::decay_t<R>, std::decay_t<D>>{std::forward<R>(r), std::forward<D>(d)}; | return unique_resource<std::decay_t<R>, std::decay_t<D>>{std::forward<R>(r), std::forward<D>(d)}; | ||||
} | } | ||||
template<class R, class D> | |||||
unique_resource<R&, std::decay_t<D>> make_unique_resource(std::reference_wrapper<R> r, D d) | |||||
noexcept(std::is_nothrow_constructible<std::decay_t<D>, D>::value) | |||||
{ | |||||
return unique_resource<R&, std::decay_t<D>>(r.get(), std::forward<D>(d)); | |||||
} | |||||
} | } | ||||
static_cast<void>(guard); | static_cast<void>(guard); | ||||
} | } | ||||
TEST_CASE("make unique resource with reference wrapper", "[UniqueResource]") | |||||
{ | |||||
REQUIRE_CALL(m, deleter(3)); | |||||
Handle h{3}; | |||||
auto guard = sr::make_unique_resource(std::ref(h), deleter); | |||||
static_cast<void>(guard); | |||||
} | |||||