From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-07-10 09:40:47
Kevin Spinar wrote:
> I feel poly_obj would be rather recognizable.
clone_ptr (or copy_ptr, or copy_on_write_ptr) is a better name from a
"marketing standpoint" than poly_obj, because it's more recognizable.
> Also, the clone_ptr library has been updated (
> http://www.peltkore.net/~alipha/clone_ptr.html ): the
> boost::*_pointer_cast functions have been implemented.
The copy on write semantics are problematic from an usability standpoint.
Consider this code:
// thread 1
int x1 = p->x;
// thread 2
int x2 = p->x;
Is this legal (assuming that both threads use the same pointer p)? You can't
tell without looking at p. If it's const, or points at const, the code is
legal. The problem is that there are no visible mutating operations in the
code; it looks innocent enough as all we do is read p->x, right?
One option is to always return a const from -> and * and provide a separate
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk