|
Boost Users : |
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2006-06-22 13:51:37
> From: "Peter Dimov" <pdimov_at_[hidden]>
> intrusive_ptr_add_ref is passed a pointer to a class with an embedded
> reference count. It doesn't matter how many typedefs resolve to X*, X
> still
> has its reference count that needs to be incremented.
>
> You only run into the problem when "assign" is underspecified and
> overloaded
> to mean different things in different contexts.
I understand your point, and maybe it is not a problem for intrusive_ptr in
all pratical cases, but intrusive_ptr_add_ref is passed a T *. T may or may
NOT be a class. ie T could be an int or an HWND (which is often just void
*, depending on #define STRICT) or some other handle, or whatever. Maybe
all those examples are a bit ugly - ie the int would have to be something
like an index into a global array, or something like that. But it is not
necessarily a distinct 'class' that holds its refcount intrinsicly. Or
maybe it is necessarily that, but only because of how intrusive_ptr_add_ref
was done, not for any other reason. So intrusive_ptr is ever so slightly
more restrictive than it need be. Probably not a big deal.
Note also, that for those few strange cases, you could also just wrap the
HWND or whatever into a class, but then of course, intrusive_ptr could have
just required the class to have a specific add_ref member function (and then
you might need to wrap all classes).
So maybe intrusive_ptr is just an example and not necessarily the best one,
but I still wonder
1. if policy based could have been the same for 95% of the cases, and better
for the last 5%,
2. there are any other techniques to consider. Either for intrusive_ptr or
boost iterators or other places where I want to use the same techniques. I
think that's the real question - if I am going to borrow some idioms for
boost or wherever, I'd like to borrow the right ones for the right
situations.
Tony
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net