|
Boost : |
From: Anand Shankar (anand.shankar.k_at_[hidden])
Date: 2007-03-24 17:03:45
Hi,
I was thinking whether it would be meaningful to have a
template<typename T, typename Clone_policy>
class Owned_ptr { ... };
where:
1) The Owned_ptr takes care of object ownership like other smart pointers;
deleting the object when the Owned_ptr is destructed.
2) The assignment operator doesn't transfer the ownership rights, but
clones the object using the Clone_polcy. This allows using the
copy constructor or a virtual clone function in the class heirarchy.
3) The copy constructor works just like assignment.
The recent projects that I've worked own have benefitted from such an helper
class.
It eases creating deep copies of complex objects;
avoids having to implement assignment operators/copy constructors
for every class.
Best regards,
Anand.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk