Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

safe C++ cleanup

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++:


void fn()
{
    anObject* = new anObject;
   
    scope([&]() {
        delete anObject;
    });
}

Name: Anonymous 2012-01-11 4:51

Oh hai wtf is the idea with the cleanup codes
if you want shit like that just use a GC language.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List