Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-05-21 11:27:28


Swadhin Bhide wrote:
> Is it possible to store CBaseObject* (base class
> pointers) in slist, hashtable, rbtree and avl tree?

No. Intrusive containers store (actually link) objects that have a
member or base hook.

> I am deriving CBaseObject from slist_base_hook,
> set_base_hook etc. But when using member_hook
> <CBaseObject*,...) and rbtree<CBaseObject*,...>,
> I am getting compiler errors. Boost documentation provides
> examples about objects and smart pointers.

boost::intrusive::list<CBaseObject> offers the same functionality as
storing pointers in a standard list. If you call:

intrusive_list.begin()->virtual_func();

You will call to virtual functions, even if the container is
boost::intrusive::list<CBaseObject>.

> But can we store raw pointers in intrusive containers?

No. See
http://www.boost.org/doc/libs/1_35_0/doc/html/intrusive/usage_when.html

For an example where base and derived classes are stored in an intrusive
container.

regards,

Ion


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