Boost logo

Boost Users :

Subject: Re: [Boost-users] How to make multi_index_container work withstd::unique_ptr?
From: Jayden Shui (jayden.shui_at_[hidden])
Date: 2011-12-20 15:53:58


My case is like that: I have a number of polymorphic objects which can be
used or referenced by other objects. I put them (the polymorphic objects)
in MIC. And if one changes its type (not only its value), its users know it
automatically by shared_ptr. I think I need MIC with shared_ptr pointing to
scoped_ptr. Am I right? Or is there other way to easy handle it? Thanks a
lot.

On Tue, Dec 20, 2011 at 3:02 PM, Andrew Holden <
aholden_at_[hidden]> wrote:

> On Tuesday, December 20, 2011 2:54 PM, Jayden Shui wrote:
> >
> > It is just my guess. In fact I need MIC with shared_ptr to a
> > scoped_ptr. The shared_ptr is used to count number of uses,
> > while the scoped_ptr used to handle polymorphic objects. I
> > feel a little nervous with that.
>
> There should be no need for both pointer types. Shared_ptr handles
> polymorphic objects just fine.
>
> A MIC holding shared_ptrs to your base class should do what you need,
> and the overhead associated with the shared_ptr should be negligible.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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