#pragma once
#include
/// ContextManager is a simple RAII object for ensuring that cleanup code runs
/// when a function exits.
class ContextManager {
/// action is the cleanup code to run.Its a std::function, so probably a
/// lambda.
std::function
/// runit lets us disable the reclamation in cases where we change our mind
bool runit = true;
public:
/// Construct a ContextManager by providing a function (lambda) to run on
/// destruct
ContextManager(std::function
/// When the ContextManager goes out of scope, run its action
~ContextManager() {
if (runit)
action();
}
/// Cancel the action, to keep it from running when this object goes out of
/// scope
void cancel() { runit = false; }
};

![[SOLVED] CS #pragma once](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] Python program that plays a guess-the-number game with magic lists](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.