
David Maisonave wrote:
"Thorsten Ottosen" <tottosen@dezide.com> wrote in message
I'm not sure I fully understand how the detection mechanism would work in your cow_ptr.
Example code: template<typename T_obj> cow_ptr(T_obj* type): m_ref_count(new ref_count(type, get_alloc_func(type))) { assert(typeid(*type) == typeid(T_obj)); }
how can that assertion ever fail when T_obj is deduced?
Since the cow_ptr works by capturing the type on the constructor, it can easily determine if the right type is being passed in, and if it matches the pointee type. That can't be done with the boost pointer containers because they don't catch the type on the constructor, nor is it part of the required logic for using a clone function method.
Nevertheless, as soon as the object is outside a cow_ptr might be sliced. That's reason enough not to allow it.
I'm not sure what you're referring to here. Can you post an example?
*ptr = *ptr2; -Thorsten