29namespace triqs::utility {
69 bool active()
const {
return active_; }
98 swap(active_, rhs.active_);
130 enum class _scope_guard_on_exit {};
133 template <
typename F> scope_guard<F> operator+(_scope_guard_on_exit, F &&f) {
return {std::forward<F>(f)}; }
143#define TRIQS_CONCAT2(X1, X2) X1##X2
146#define TRIQS_CONCAT(X1, X2) TRIQS_CONCAT2(X1, X2)
151#define SCOPE_EXIT auto TRIQS_CONCAT(SCOPE_EXIT_ANONYMOUS_VARIABLE, __COUNTER__) = triqs::utility::detail::_scope_guard_on_exit{} + [&]()
153#error "__COUNTER__ not defined for this compiler"
RAII wrapper that invokes a callable when it goes out of scope, unless dismissed.
scope_guard & operator=(const scope_guard &)=delete
Copy assignment is disabled: a guard owns a unique cleanup action.
scope_guard(scope_guard &&rhs) noexcept
Move constructor.
scope_guard(const scope_guard &)=delete
Copy construction is disabled: a guard owns a unique cleanup action.
bool active() const
Query whether the guard is still active.
~scope_guard()
Destructor.
scope_guard()=delete
Default construction is disabled: a guard must always wrap a callable.
scope_guard(F f)
Construct a guard from a callable.
scope_guard & operator=(scope_guard &&rhs) noexcept
Move assignment.
void dismiss()
Disable the guard so the stored callable is not invoked on destruction.
scope_guard< F > make_scope_guard(F f)
Build a scope_guard from a callable.
scope_guard< F > exec_at_scope_exit(F f)
Build a scope_guard from a callable.