From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-08-04 13:18:41
Philippe A. Bouchard wrote:
>I made a different version of ptr<> that handles polymorphic pointers.
>The speed of the class is mainly depended on the number of distinct new U
>allocations that are first encountered. Once they are encountered it is as
Please explain further what you mean by "distince new U allocations...". Is
U the ptr template argument.
>+ sizeof(ptr<T>) = sizeof(T *);
I've tried to figure how this would work without having at least 2 pointers
in ptr<T>. One to hold the reference count and the other to hold the
T*. Otherwise, I don't see how ptr can handle multiple inheritance.
I've uploaded into the files ptr_evans folder the best I could do. Could
you explain more how you've achieved this? I've read the previous
posts and I tend to agree with Heintzelman's 7/30 post. I just don't see
how you can avoid 2 pointers. The first, m_gen (see ptr_evans/ptr.hpp),
to hold the count AND the pointer to the base of the object, and the 2nd,
m_ptr, to hold the possibly interior pointer to the start of a muliply
inherited class. The difference between ptr.hpp and ptr.h is:
1) Easier reference to the counter due to the counter being multiply
with the pointed to object of type _T.
2) Instead of ptr(T*) there is ptr(gen_type*). This is an advantage
doesn't require any modification of new to allocate the refcount ahead
T and no reinterpret casts to get such a pointer to work.
However, the main purpose of this email is to get some idea of how you've
avoided the need for 2 pointers to handle the multiple inheritance problem.
>+ once different associations are made large containers can take advantage
>of the memory and speed benefits (pool usage cannot do that);
>- sizeof(new () T) = sizeof(T) + sizeof(int) * 2;
I don't understand. This seems to indicate the size of a pointer (i.e.
new () T)
is > sizeof(T), but if T contains a pointer, this can't be true.
>- speedof(* ptr<T>) = speedof(* T) + C.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk