|
opm-simulators
|
A simple class which makes sure that a cleanup function is called once the object is destroyed. More...
#include <genericguard.hh>
Public Member Functions | |
| GenericGuard (Callback &callback) | |
| GenericGuard (GenericGuard &&other) | |
| GenericGuard (const GenericGuard &other)=delete | |
| void | setEnabled (bool value) |
| Specify whether the guard object is "on duty" or not. | |
| bool | enabled () const |
| Returns whether the guard object is "on duty" or not. | |
A simple class which makes sure that a cleanup function is called once the object is destroyed.
This class is particularly useful in conjunction with lambdas for code that might throw exceptions.
|
inline |
Specify whether the guard object is "on duty" or not.
If the guard object is destroyed while it is "off-duty", the cleanup callback is not called. At construction, guards are on duty.