Add guard on forwarding constructor

This commit is contained in:
Jeremy Rifkin 2025-02-20 22:22:46 -06:00
parent 03b292c20b
commit 477aecec01
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4

View File

@ -283,7 +283,10 @@ namespace detail {
F f;
bool active;
public:
template<typename G>
template<
typename G,
typename std::enable_if<!std::is_same<typename std::decay<G>::type, scope_guard<F>>::value, int>::type = 0
>
scope_guard(G&& f) : f(std::forward<F>(f)), active(true) {}
~scope_guard() {
if(active) {