Boost logo

Boost :

From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2007-08-10 10:47:23


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?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk