|
Re: Is intrusive_ptr the thing to use?: msg#00314lib.boost.user
From: "Hickman, Greg" <greg.hickman@xxxxxxxx> [...] > Its seems the leaf itself must implement the factory method/weak_this idiom. > This initially didn't seem like a good idea in our case since clients write > the leaves - we only provide X. But on second thought, perhaps two > alternatives are (1) provide a helper template for clients to use when > deriving from X to automatically declare the static create()/weak_this pair, Yes, this is what I have done in the CVS with enable_shared_from_this. You could provide template<class T> class enable_shared_from_this { private: weak_ptr<T> weak_this; public: static shared_ptr<T> create() { shared_ptr<T> pt(new T); pt->weak_this = pt; return pt; } shared_ptr<T> shared_from_this() { shared_ptr<T> pt(weak_this); return pt; } }; and let clients define their leaves as class leaf: public enable_shared_from_this<leaf> { // ... }; > or (2) use an intrusive reference counting approach for X. > > If an intrusive approach ultimately works better for us, what should I do as > a boost 1.29.0 user: use counted_base/shared_from_this, or intrusive_ptr > (which I admittedly haven't even looked at)? The counted_base/shared_from_this mechanism will not be present in the next release, so if the above doesn't work for you, it seems that intrusive_ptr would be a better choice. ------------------------ 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: 00314, Kresimir Fresl |
|---|---|
| Next by Date: | MSVC++, bind and namespaces: 00314, Andre Hentz |
| Previous by Thread: | RE: Is intrusive_ptr the thing to use?i: 00314, Hickman, Greg |
| Next by Thread: | Lambda questions: 00314, Claus Rasmussen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |