Very little optimization by using a simpler scope_guard when possible

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
This commit is contained in:
louiz’
2016-10-20 19:32:20 +02:00
parent 6b4d2e8e3e
commit ce06c25e93
3 changed files with 11 additions and 6 deletions
+7
View File
@@ -1,6 +1,7 @@
#pragma once
#include <functional>
#include <memory>
#include <vector>
/**
@@ -85,5 +86,11 @@ private:
};
template<typename F>
auto make_scope_guard(F&& f)
{
return std::unique_ptr<void, std::decay_t<F>>{(void*)1, std::forward<F>(f)};
}
}