Boost logo

Boost :

Subject: Re: [boost] [SmartPointers] Determine interest in a new pointer wrapper class "flex_ptr"
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-03-22 22:50:16

On 23/03/2015 11:04, Jakob Riedle wrote:
> In the last few weeks, I heavily felt the lack of boost not having a
> more lightweight solution to a "not-necessarily-owning" pointer-wrapper
> than shared_ptr.
> shared_ptr is quite slow in the context that I need it to work.
> Furthermore it always is owning, even though ownership is shared in
> between instances.
> This is unhelpful, if you have an std::list of both non-owning and
> owning pointers.
> Hence, if you do not want to use shared_ptr all over your project,
> or especially want to interact with C, you need a not-necessarily-
> owning pointer-wrapper.

While I agree that shared_ptr is sometimes heavier than I would like,
I'm having a hard time wrapping my head around potential use cases of
such a pointer. I'm not saying there aren't any, but all cases that I
can think of having a pointer collection would use either all-owned
(unique or shared) or none-owned (weak). A heterogeneous collection
feels weird.

Can you explain your envisaged use cases in more detail perhaps, and why
you think shared_ptr/weak_ptr is not the right choice for those cases?

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