
Olaf Krzikalla wrote:
// Ok, let's try non-intrusive Intrusive ;-)
typedef std::map<bar*,intrusive::slist_node_mgmt_data<bar> > bar_chainer;
struct bar_mgmt { bar_chainer& bar_management_; bar_mgmt(bar_chainer& b) : bar_management_(b) {}
slist_node_mgmt_data<bar>& operator()(bar& that) { return bar_management_[&that]; } };
void bar_test() { // now a local variable is feasible: std::map<bar*,intrusive::slist_node_mgmt_data<bar> > bar_management;
intrusive::slist<bar, bar_mgmt> my_list(bar_mgmt(bar_management)); // aso. }
//--------------------------------------
Something along those lines. Of course the user is now responsible for the proper lifetime management of bar_management. But I don't consider this to be an big issue as it is a typically problem of functors containing references.
Why not make the bar_management a static member of the function objet, rather?