Boost logo

Boost Users :

Subject: Re: [Boost-users] Please help me to choose a container
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-12-20 18:40:52


2011/12/20 Jayden Shui <jayden.shui_at_[hidden]>

> Hi All,

Hi Jayden,

>
> I have a number of named objects of type B whose name can be accessed by
> B::Name(). B is polymorphic. D1, D2 and so on are derived from B. I want to
> put them in a set or map-like container ordered by their names. They are
> referenced by other objects, such as of type C. If the objects in the
> container are changed by its type (from type D1 to D2)
>

How can an object change it's type? Don't you need to erase an object and
create a new one to achieve that?

 or value, their users can know it automatically, i.e. those information is
> shared among owners and users. To erase an object in the container, first
> we need to ensure it is not be used by other objects.
>
> Please help me on choose a proper container with smart pointers. I am
> struggling with it by trying multi-index-container, pointer container,
> standard container, and cannot find a good way.
>

My first guess would be write your own container adaptor, that uses
std::set/map< shared_ptr<B>, your_compare >...

Regards
Kris



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