
David Maisonave wrote:
"Sam Partington" <sam.partington@gmail.com> wrote in message news:<546fdb840601060205w76ed8be9n2bf73c4323c78c20@mail.gmail.com>...
I don't agree with that. The clone concept is a well established idiom for polymorphic types. Sure missing out a clone _does_ lead to slicing, but that is understood, and as Thorsten says we can help check for that with an assert. We can only help the user to get it write, we can't do it all for them.
The cow_ptr and the copy_ptr can use the same assert code to catch slicing. The assert logic can be placed in the constructor of the cow_ptr and copy_ptr. This would make it easier to catch slicing in the cow_ptr/copw_ptr *than* it would be in the boost pointer containers. That's because in the boost pointer containers you would only catch slicing via assert if and when the object is clone. If the object never gets clone during testing, you would never catch the slicing.
With cow_ptr/copy_ptr the slicing would be caught when the object gets instantiated. So you have a much higher probability of catching slicing using the cow_ptr clone method, *than* you would using the boost pointer container method.
I'm not sure I fully understand how the detection mechanism would work in your cow_ptr. Nevertheless, as soon as the object is outside a cow_ptr might be sliced. That's reason enough not to allow it. -Thorsten