52#include "TasksConfig.h"
56template <
typename tFn = std::function<
void()>>
65 : m_fn(std::move(in_fn))
73 : m_fn(std::move(in_other.m_fn))
79 m_fn = std::move(in_other.m_fn);
110 std::optional<tFn> m_fn;
114template <
typename tFn>
Definition: FunctionGuard.h:58
FunctionGuard(FunctionGuard &&in_other) noexcept
Move constructor.
Definition: FunctionGuard.h:72
FunctionGuard & operator=(nullptr_t) noexcept
Null-pointer assignment operator (calls Forget() to clear the functor)
Definition: FunctionGuard.h:83
~FunctionGuard()
Destructor.
Definition: FunctionGuard.h:68
FunctionGuard & operator=(FunctionGuard< tFn > &&in_other) noexcept
Move assignment operator.
Definition: FunctionGuard.h:77
void Execute()
Executes and clears the functor (if bound)
Definition: FunctionGuard.h:96
void Forget() noexcept
Clear the functor (without calling it)
Definition: FunctionGuard.h:104
bool IsBound() noexcept
Returns whether functor has been bound to this FunctionGuard.
Definition: FunctionGuard.h:92
FunctionGuard(nullptr_t)
Default constructor.
Definition: FunctionGuard.h:61
FunctionGuard(tFn in_fn)
Functor constructor.
Definition: FunctionGuard.h:64
FunctionGuard MakeGenericFnGuard(std::function< void()> in_fn)
Create a generic function guard (preferable when re-assigning new functor values to the same variable...
Definition: FunctionGuard.h:121
FunctionGuard< tFn > MakeFnGuard(tFn in_fn)
Create a function guard (directly stores the concretely-typed functor in the FunctionGuard)
Definition: FunctionGuard.h:115