Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-12-29 08:53:54


"Dan" wrote in message news:02ec01c3ce06$15b5fdc0$73071ed3_at_nesottolap...
>
[snip]
> Ever since I discovered the safety, versatility and power of shared_ptr,
> I've never used auto_ptr again. Your pointer containers work as if they
> were storing auto_ptr's. What I was suggesting was *not* that they store
> shared_ptr's, but to have the ability to specify that they work *as if*
> storing shared_ptr's.

hm..I have a hard time imagining this.

> >> ptr_vector< shared_ptr<X> > would allow pointer containers to share
> >> ownership, and would interface via shared_ptr<>'s; and...
> >
> >what interface did you have in mind.?
>
> push_back( shared_ptr<T> t );
> shared_ptr<T> ptr_begin();
> shared_ptr<T> ptr_iterator(); //and so on, for the shared_ptr<T>
> specialization

what should the reference count then be for a returned shared_ptr?

> A use-count paradigm has infinitely more applications than merely
> de-allocation. But even when de-allocation is intended, a custom allocator
> might actually benefit from a call back on de-allocation, such as to delay
> or buffer de-allocations, or to recycle rather than actually de-allocate
> the memory, without having to overload new and delete for the objects in
> question.
> Being able to remove objects from the container's ownership may be as
> important as to place them into it.
> And the ability to have pointers to an object in more than one container,
> with shared ownership, would be very desirable, almost indispensable I'd
> say.

ok. I don't know if this is easy to implement. Would a deleter object passed
to
the constructor be preferable?

> The way I understand your pointer containers, you've achieved two things:
> 1) They work *as if* storing auto_ptr<>'s but with higher efficiency and
> better performance.
> 2) Syntax is simplified when using algorithms, such as "for_each".
>
> What I wish to convince you of is:
> A) that point 2 is very important in its own right, even in situations
when
> you don't want ownership by the container, such that the semantics would
be
> *as if* storing weak_ptr<>'s.

How do you imagine the implementation for that?

> Cheers!
>
> Dan
>
> P.S.: Feel free to re-post this email to the mailing list; I just tire of
> starting a new thread each time.. :(
> How does one *reply* to a message?

In eg outlook express, you click the message an press reply.

br

Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk