|
Re: Is intrusive_ptr the thing to use?: msg#00298lib.boost.user
From: "Hickman, Greg" <greg.hickman@xxxxxxxx> > > From: Peter Dimov [mailto:pdimov@xxxxxxxxx] > > If 'f' is virtual, have the object store a weak_ptr to itself: > > > > class X > > { > > private: > > > > weak_ptr<X> weak_this; > > > > X(); > > X(X const &); > > X& operator=(X const &); > > > > public: > > > > static shared_ptr<X> create() > > { > > shared_ptr<X> px(new X); > > px->weak_this = px; > > return px; > > } > > I must be missing something here, because it appears as though you can't > derive a Y from X and still initialize X::weak_this. You could simply make X::weak_this and X::X() protected... although if you follow the design rule that says that non-leaf classes should be abstract (and if possible contain no data) this shouldn't be necessary, as X as pictured above would be a leaf. ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/EbFolB/TM ---------------------------------------------------------------------~-> Info: <http://www.boost.org> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl> Unsubscribe: <mailto:boost-users-unsubscribe@xxxxxxxxxxxxxxx> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ublas::matrix sharing storage with ublas::vector: 00298, Toon Knapen |
|---|---|
| Next by Date: | Re: Re: solaris gcc 3.2 stlport regexp (bug?): 00298, John Maddock |
| Previous by Thread: | RE: Is intrusive_ptr the thing to use?i: 00298, Hickman, Greg |
| Next by Thread: | RE: Is intrusive_ptr the thing to use?: 00298, Hickman, Greg |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |