0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-02 13:48:53 +02:00

ircd::util: Prevent scope copying / minor cleanup.

This commit is contained in:
Jason Volk 2016-09-11 20:46:16 -07:00
parent 5b607b5b1f
commit a4e810d1c8

View file

@ -74,18 +74,24 @@ struct scope
{
const std::function<void ()> func;
template<class F>
scope(F &&func)
:func(std::forward<F>(func))
{
}
~scope()
{
func();
}
template<class F> scope(F &&func);
scope(const scope &) = delete;
~scope() noexcept;
};
template<class F>
scope::scope(F &&func)
:func(std::forward<F>(func))
{
}
inline
scope::~scope()
noexcept
{
func();
}
// For conforming enums include a _NUM_ as the last element,
// then num_of<my_enum>() works