|
Boost : |
From: Max Khesin (MKhesin_at_[hidden])
Date: 2004-07-07 16:00:20
As of version 3.1 boost shared_ptr has a constructor that takes a
user-defined deleter:
template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d)
{
detail::sp_enable_shared_from_this(p, p, pn);
}
Maybe I missed something, but what is your library adding to this?
m
-----Original Message-----
From: Maciej Sobczak [mailto:prog_at_[hidden]]
Sent: Wednesday, July 07, 2004 4:18 PM
To: boost_at_[hidden]
Subject: [boost] Generalizing the shared_ptr
<< File: scoped_handle.h >> << File: test.cc >> << File: ATT57508.txt >>
Hi,
(not sure if it was discussed before)
I've found Boost smart pointers inflexible in the sense that they
operate only on pointers.
It would be a good idea to generalize their interface to handle just
about anything that requires special care when destroying.
HANDLE (on Windows), FILE*, file descriptors (on Unix), third-party API
handles, etc. come to mind.
I wrote a very simple class (see attachments), scoped_handle, which
encapsulates the resource (whatever it is) and its disposing (whatever
that means).
The techniques used are similar to those used in implementation of
boost::shared_ptr.
The example file shows how the class can be used to guard resources
allocated by operator new, fopen, open, etc.
Is it possible to achieve the same results with the existing Boost
libraries?
If not, is there any interest in developing this kind of class?
-- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk