53template <
typename TFunc>
62 : m_func(
std::forward<TFunc>(func)),
75 : m_func(
std::move(guard.m_func)),
76 m_engaged(
std::move(guard.m_engaged))
109 typename std::remove_reference<TFunc>::type m_func;
128template <
typename TFunctor>
155template <
typename TFunc,
158ScopeGuard<
decltype(std::bind(std::forward<TFunc>(func),
159 std::forward<TParams>(args)...))>
161 auto bindObj = std::bind(std::forward<TFunc>(func), std::forward<TParams>(args)...);
Implements Scope Guard Idiom.
Definition ScopeGuard.h:55
ScopeGuard(const ScopeGuard &guard)=delete
No copy is allowed.
void release()
Release the bound functor.
Definition ScopeGuard.h:96
~ScopeGuard() noexcept
Destructor.
Definition ScopeGuard.h:84
bool isReleased() const
Check whether the functor is released.
Definition ScopeGuard.h:103
ScopeGuard(TFunc &&func)
Constructor.
Definition ScopeGuard.h:61
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:157
ScopeGuard< TFunctor > makeScopeGuard(TFunctor &&func)
Create scope guard with provided functor.
Definition ScopeGuard.h:129
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.