From: Csaba Szepesvari (cszepes_at_[hidden])
Date: 2003-05-13 03:59:09
I've created a folder strong_ptr in boost/files and uploaded some files
implementing a smart pointer with copy semantics supporting polymorphic copy
when used with cloneable objects (a proposed class to support cloneing) along
with an example.
Question if there is any interest in such an artifact.
The typical usage is:
- as a member of a composite class that needs to manage a polymorphic object
- supporting the implementation of the pimpl idiom
In the former case strong_ptr frees the user of the burdon of having to write
custom destructors/copy constructors/.. and hence encourages a good practice..
IMHO strong_ptr complements nicely shared_ptr and scoped_ptr.
It is similar to Peter Dimov's impl_ptr and it could be that Peter's impl_ptr
could provide a sutiable implementation.
Main differences to impl_ptr:
- simpler implementation (and probably less complete as well)!
- default semantics supports polymorphic copy; decision is made at compile time
except on MSVC versions not supporting partial template specialization (PTS)
[btw, the .NET 2003 compiler does support PTS, right?]
Polymorphic copy is supported through a clone function dispatching the call to
either the objects copy constructor when the underlying class is not a
"cloneable" derived class, otherwise calling the clone member.
This leaves open the possibility to extend cloneing support to other types of
polymorphic objects (not only to cloneable derived classes).
(Not available on compilers not supporting PTS).
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk