News for hackers. Stuff that matters.
Re:Implementing Go's defer keyword in C++ by Too on Sunday October 22, 2017 @01:27AM (#15525298)
std::unique_ptr has a widely unknown second template argument called deleter. It is designed exactly for this purpose. You just do roughly like this(written from a phone):

    typedef fdwrapper = unique_ptr<int, close>;
    fdwrapper fdhandle(open(filename));

There are no comments on this comment yet.