Boost logo

Boost :

From: Vladimir Batov (batov_at_[hidden])
Date: 2007-10-05 18:01:19


> Why use a boost::shared_ptr?

shared_ptr is an extremely versatile and poweful gadget. One (among others)
thing it handles well is incomplete classes for implementation hiding. Maybe
there are other smart pointers doing that sort of thing cheaper. I am not
sure.

> You want your implementation details to be
> shared across all 'Test's?
> What you need is more like a deep-copying smart pointer.

It certainly depends on application. Like if I have a GUI widget, then I do
not want to deep-copy it. If I have static read-only configuration data, I
do not want deep-copying those either.

Deep-copying vs. shallow-copying is a separate issue that is likely to be
addressed via an additional policy template parameter. I did not want to
blow up my example with all the bells and whistles for smaller code
foot-print and so that the main idea stands out clearer.

Best,
Vladimir.


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