From ce06c25e93183282be42ab79bfed2ab7c02791ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Oct 2016 19:32:20 +0200 Subject: Very little optimization by using a simpler scope_guard when possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The version with the vector, that can be disabled etc, is “very” slow, so we use unique_ptr when we don’t need to disable it, and when it only contains one function --- louloulibs/utils/scopeguard.hpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'louloulibs/utils/scopeguard.hpp') diff --git a/louloulibs/utils/scopeguard.hpp b/louloulibs/utils/scopeguard.hpp index ee1e2ef..cd0e89e 100644 --- a/louloulibs/utils/scopeguard.hpp +++ b/louloulibs/utils/scopeguard.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include /** @@ -85,5 +86,11 @@ private: }; +template +auto make_scope_guard(F&& f) +{ + return std::unique_ptr>{(void*)1, std::forward(f)}; +} + } -- cgit v1.2.3