Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-07-23 13:36:21

"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> I was talking about Loki::SmartPtr. I'm not familiar with policy-based
> smart pointers but I suspect it is template-based?

As is squad_ptr<>. Or perhaps the part that says:

template <typename _Tp>
    struct squad_ptr;

means something other than what I think it means.

> If so it would still be more complex to use because you'll have to wrap
> typenames with a real class.

??? Umm...if squad_ptr<> is "template-based", does that mean it's
"more complex to use" and that you "have to wrap typenames with a
real class"? Loki::SmartPtr can be used directly, or with a type
generator, or with a wrapper. The only discussion on declaring smart
pointers was whether the average user would want to specify all the
policy parameters.

> It will become difficult to manage if you are pointing to a children of
> class inheriting mutiple times the same parent for example. Which
> counter will it use under badly designed projects like this one?

Depends on how badly you designed it. If you have an intrusive count
which you inherited from multiple times, without using virtual
inheritance, then you will probably have some big problems. This is
true of any intrusive count. It is not specific to boost::instrusive_ptr
or Loki::SmartPtr with intrusive policies. Of course, asking this
question is somewhat like asking: "What will your allocator do if I
delete a block three times in a row, and then try to write 0 in every
memory location on my system?" Well, the obvious answer is: "It will
break" and "Don't do that."

> Can it be applied to TrollTech's QListView for example?

I'm not familiar with that, but I don't see why not.

"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> [...]
> ... and a little bit more difficult to find discussions about those also.

Did you check the ASPN site that archives Boost? There's a link to
it on the main Boost page, I believe. It has a search engine just for
Boost, and Google apparently indexes quite a bit as well. Around
March-May, you should see quite a flurry of messages regarding
smart pointers in general, and policy-based ones in particular. If
you absolutely can't find the messages, I will be happy to provide
you with links.

> [...]
> Would it be possible to start using partial template specializations
> like:
> template <class _T>
> class shared_ptr< squad_target<_T> >
> {
> ...
> };
> to remove exception handling and to optimize for pure speed?

That looks like it would modify the semantics of shared_ptr, so
you would have to ask Peter Dimov or one of the other smart_ptr
authors/gurus about that. My guess is that the response will be
along the lines of: "shared_ptr does not have high performance
as a design goal, and thus such modifications are not desirable".
For most applications, it would be hard to show that shared_ptr
is restrictively slow (that is, slow in a way that makes a noticeable
and unacceptable difference in performance). Boost is a
collection of general-interest libraries. For the cases where a
stripped-down smart pointer with blazing speed is essential, one
must ask how many people have a need for such a thing. If you
can motivate the design by showing that there is a significant
demand for such performance, you may be able to convince
people of the need for such designs. However, shared_ptr has
been around a fairly long time, and apparently, not many people
have complained about its speed so far.


Boost list run by bdawes at, gregod at, cpdaniel at, john at