mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -8,44 +8,37 @@ namespace base
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
/// Base class for all ScopeGuards.
|
||||
class GuardBase
|
||||
/// Base class for all ScopeGuards.
|
||||
class GuardBase
|
||||
{
|
||||
public:
|
||||
/// Disable ScopeGuard functionality on it's destruction
|
||||
void release() const { m_bDoRollback = false; }
|
||||
|
||||
protected:
|
||||
GuardBase() : m_bDoRollback(true) {}
|
||||
|
||||
// Do something in the destructor
|
||||
mutable bool m_bDoRollback;
|
||||
};
|
||||
|
||||
/// ScopeGuard for specific functor
|
||||
template <typename TFunctor>
|
||||
class GuardImpl : public GuardBase
|
||||
{
|
||||
public:
|
||||
explicit GuardImpl(TFunctor const & F) : m_Functor(F) {}
|
||||
|
||||
~GuardImpl()
|
||||
{
|
||||
public:
|
||||
/// Disable ScopeGuard functionality on it's destruction
|
||||
void release() const
|
||||
{
|
||||
m_bDoRollback = false;
|
||||
}
|
||||
if (m_bDoRollback)
|
||||
m_Functor();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
GuardBase() : m_bDoRollback(true)
|
||||
{
|
||||
}
|
||||
|
||||
// Do something in the destructor
|
||||
mutable bool m_bDoRollback;
|
||||
};
|
||||
|
||||
/// ScopeGuard for specific functor
|
||||
template <typename TFunctor> class GuardImpl : public GuardBase
|
||||
{
|
||||
public:
|
||||
explicit GuardImpl(TFunctor const & F) : m_Functor(F)
|
||||
{
|
||||
}
|
||||
|
||||
~GuardImpl()
|
||||
{
|
||||
if (m_bDoRollback)
|
||||
m_Functor();
|
||||
}
|
||||
|
||||
private:
|
||||
TFunctor m_Functor;
|
||||
};
|
||||
} // namespace impl
|
||||
private:
|
||||
TFunctor m_Functor;
|
||||
};
|
||||
} // namespace impl
|
||||
|
||||
typedef impl::GuardBase const & scope_guard;
|
||||
|
||||
@@ -55,7 +48,7 @@ impl::GuardImpl<TFunctor> make_scope_guard(TFunctor const & F)
|
||||
{
|
||||
return impl::GuardImpl<TFunctor>(F);
|
||||
}
|
||||
} // namespace base
|
||||
} // namespace base
|
||||
|
||||
#define SCOPE_GUARD(name, func) \
|
||||
::base::scope_guard name = base::make_scope_guard(func); \
|
||||
|
||||
Reference in New Issue
Block a user