Re: [boost] Performance comparison between ptr_vectorandvector<cow_ptr<Shape> >, vector<copy_ptr<Shape> >

"Thorsten Ottosen" <tottosen@dezide.com> wrote in message news:<dpmc2d$f75$1@sea.gmane.org>...
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?
The only way that cow_ptr and copy_ptr can get slice is if the wrong type is pass to the constructor. Example code: Derivedtype* p = new DerivedDerivedType; cow_ptr<BaseType> pBase(p); //This will cause an assertion since p type does not match the pointee
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;
Can you please give a more complete example? Which is the smart pointer, here, and exactly what type of pointers?

David Maisonave wrote:
I'm not sure what you're referring to here. Can you post an example?
*ptr = *ptr2;
Can you please give a more complete example? Which is the smart pointer, here, and exactly what type of pointers?
let's assume non of the types involved are abstact. Anyway, we have been here before and are starting to move in circles. -Thorsten
participants (2)
-
David Maisonave
-
Thorsten Ottosen