I am currently modifying a complex class that has nodes pointing to themselves just like linked lists or graphs. I want it to be used in shared memory using boost::interprocess functions. Now I am looking for the way to redesign it such that it stays generic and involves least changes.
template< class T >
class node {
public:
T data;
node* prev;
node* next;
};
The redesign should make use of the boost::interprocess::allocator allocator in order to implicitly use the relative smart pointers of type boost::interprocess::offset_ptr. I thought it should involve a second template parameter like
template< class T, class alloc_type = std::allocator< node< T > > >
class node {
public:
T data;
typename alloc_type::pointer prev;
typename alloc_type::pointer next;
};
which of course doesn't work due to cyclic dependencies just as with references.
I hope a can get some help from a C++ class template pro on the best way to implement it. I had a look at the boost shared memory enabled containers but they are solving it in a rather complicated manner that involves several external classes.
Joh