On Thu, 2 Oct 2003 18:38:26 +0200 (CEST) Robert Vazan <[EMAIL PROTECTED]> wrote:

RV> Boost's shared_ptr requires complete types at point of instantiation.

 No, quoting from http://www.boost.org/libs/smart_ptr/shared_ptr.htm

        The class template is parameterized on T, the type of the object
        pointed to. shared_ptr and most of its member functions place no
        requirements on T; it is allowed to be an incomplete type, or void

RV> > RV> So changes that I would want to make are (a) use templates, (b) allow
RV> > RV> forward declarations, and (c) use separate type for return values. Only (b)
RV> > RV> is essential to make smart pointers useful, but (a) and (c) make it better.
RV> > 
RV> >  Sorry, what do you mean by (c)?
RV> 
RV> It gives performance improvements. Return pointer with different type can
RV> have different, more efficient assignments. Assigning from return pointer
RV> to normal pointer or to another return pointer transfers ownership skipping
RV> one IncRef/DecRef round.

 Well, yes, but I have some troubles to believe that we're going to notice
any difference from saving an Inc/DecRef()... it does create many
opportunities for adding new and exciting bugs however (including compiler
bugs BTW).

RV> Gcc gives very little difference. Macros compile in 12 minutes and 43
RV> seconds. Templates compile in 12 minutes and 38 seconds. I am attaching
RV> patch so you can try it with Visual C++.

 Ok, I did, thanks. The compile time are similar, after changing MObject.h
(so it's not full rebuild, but pretty close) I get 2:39 for templates and
2:22 with macros, so I guess you should go ahead and change this if you
want to (please don't misunderstand me: I do think it would be nice, too,
it's just that I can't really persuade myself that it's the most important
thing to do...). A word of caution: your patch didn't compile here because
there is also SpamManager::Pointer and VC6 was unhappy about using the same
name as template class and "normal" class, so you shouldn't use such name
(well you shouldn't use it anyhow, it's too generic...). Also, if you want
my implementation of SharedPtr which is known to work with VC6 (and gcc but
this is simple[r]), let me know and I'd mail it to you.

 Thanks,
VZ



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-Developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-developers

Reply via email to