Name: Anonymous 2012-01-11 1:33
I was thinking about safe C++ resource cleanup.
You could create an object and pass it a lambda that contains the cleanup code.
When the object's destructor is called it will run the lambda.
I got this idea from D's scope constructs.
rough sample in C++:
You could create an object and pass it a lambda that contains the cleanup code.
When the object's destructor is called it will run the lambda.
I got this idea from D's scope constructs.
rough sample in C++:
void fn()
{
anObject* = new anObject;
scope([&]() {
delete anObject;
});
}