52template <
typename TFunc>
61 : func_(
std::forward<TFunc>(func)),
75 : func_(
std::move(guard.func_)),
76 engaged_(
std::move(guard.engaged_))
110 typename std::remove_reference<TFunc>::type func_;
129template <
typename TFunctor>
156template <
typename TFunc,
159ScopeGuard<
decltype(std::bind(std::forward<TFunc>(func),
160 std::forward<TParams>(args)...))>
162 auto bindObj = std::bind(std::forward<TFunc>(func), std::forward<TParams>(args)...);
Implements Scope Guard Idiom.
Definition ScopeGuard.h:54
ScopeGuard(const ScopeGuard &guard)=delete
No copy is allowed.
void release()
Release the bound functor.
Definition ScopeGuard.h:97
~ScopeGuard() noexcept
Destructor.
Definition ScopeGuard.h:85
bool isReleased() const
Check whether the functor is released.
Definition ScopeGuard.h:104
ScopeGuard(TFunc &&func)
Constructor.
Definition ScopeGuard.h:60
auto makeScopeGuard(TFunc &&func, TParams... args) -> ScopeGuard< decltype(std::bind(std::forward< TFunc >(func), std::forward< TParams >(args)...))>
Create scope guard by binding the provided function and all the arguments.
Definition ScopeGuard.h:158
ScopeGuard< TFunctor > makeScopeGuard(TFunctor &&func)
Create scope guard with provided functor.
Definition ScopeGuard.h:130
ScopeGuard(ScopeGuard &&guard)
Move constructor.
Definition ScopeGuard.h:74
ScopeGuard & operator=(const ScopeGuard &guard)=delete
No copy is allowed.
Main namespace for all classes / functions of COMMS library.