add a class wrapping a cleanup function called when the class instance is out of scope. useful to clean up C resources in a lambda function