
Christian Holmquist wrote:
Hi,
I have a class X : public intrusive::list_base_hook<> and would like to embed an additional member bool using the pointer_plus_bit.
Can this be achieved using the value_traits somehow, and have the list working 'appropriately'?
It can be achieved using value_traits. Just repeat the following example:
http://www.boost.org/doc/libs/1_35_0/doc/html/intrusive/value_traits.html#in...
but instead of defining this value_traits:
//Define the node traits. A single node_traits will be enough.
struct simple_node_traits
{
typedef simple_node node;
typedef node * node_ptr;
typedef const node * const_node_ptr;
static node *get_next(const node *n)
{ return n->next_; }
static void set_next(node *n, node *next)
{ n->next_ = next; }
// ...
};
Use this (supposing you want to embed the bit in the next pointer):
struct simple_node_traits
{
// ...
static node *get_next(const node *n)
{ return pointer_plus_bit