mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::util: Prevent scope copying / minor cleanup.
This commit is contained in:
parent
5b607b5b1f
commit
a4e810d1c8
1 changed files with 16 additions and 10 deletions
|
@ -74,17 +74,23 @@ struct scope
|
|||
{
|
||||
const std::function<void ()> func;
|
||||
|
||||
template<class F> scope(F &&func);
|
||||
scope(const scope &) = delete;
|
||||
~scope() noexcept;
|
||||
};
|
||||
|
||||
template<class F>
|
||||
scope(F &&func)
|
||||
scope::scope(F &&func)
|
||||
:func(std::forward<F>(func))
|
||||
{
|
||||
}
|
||||
|
||||
~scope()
|
||||
inline
|
||||
scope::~scope()
|
||||
noexcept
|
||||
{
|
||||
func();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// For conforming enums include a _NUM_ as the last element,
|
||||
|
|
Loading…
Reference in a new issue