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:
@@ -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)};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user