Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2002-01-25 14:17:52


From: "Darin Adler" <darin_at_[hidden]>
> Peter Dimov's revision to the Boost smart_ptr class templates is now in
> Boost CVS. What follows is a summary of differences between the old
> smart_ptr and the new smart_ptr. For brevity, I usually mention only
> shared_ptr or scoped_ptr, but the features of shared_array and scoped_array
> are almost identical.

Big thanks to Peter and Darin!

> ...
> The new shared_ptr can be constructed with a custom deallocator. This
> often-requested feature allows things like a shared_ptr<std::FILE>.

E.g.
    
    shared_ptr<FILE> shared_file (const char* name, const char* mode) {
        if (FILE* p = fopen(name,mode))
            return shared_ptr<FILE>(p,fclose);
        return 0;
    }

The deleter can be either a function like fclose, or a function object.

Very cool, IMHO.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk