Boost logo

Boost Users :

Subject: Re: [Boost-users] How to make multi_index_container work withstd::unique_ptr?
From: Igor R (boost.lists_at_[hidden])
Date: 2011-12-20 18:01:36


> What I mean is dynamic changing. For example
>
> class B {public: virtual ~B()}  // Base class.
> class D1 : public B {}            // D1 derived from B
> class D2 : public B {}            // D1 derived from B
>
> scoped_ptr<B> p = new D1;   // pointing to D1
> p.reset(new D2);    // change pointing to D2
>
> If they are shared between owners and users, I need type
>
>        shared_ptr<scoped_ptr<B>>
>
> But this type make my code hard to develop and also read.

And what's wrong with just shared_ptr<B>? Why do you need the
additional level of indirection?


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