[Boost-bugs] [Boost C++ Libraries] #3489: using member objects as hooks

Subject: [Boost-bugs] [Boost C++ Libraries] #3489: using member objects as hooks
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-26 22:02:36


#3489: using member objects as hooks
------------------------------+---------------------------------------------
 Reporter: anonymous | Owner: igaztanaga
     Type: Feature Requests | Status: new
Milestone: Boost 1.41.0 | Component: intrusive
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 boost intrusive supports base hooks and member hooks, but if you need
 something like the following you're off to writing value and node traits:

 struct B : list_base_hook<>{};

 struct A{
   B *b;
 };

 the value type of the list should be A, not B, so neither a base_hook nor
 a member hook can be used here.

 so I suggest to add code like the one attached to this ticket, which
 allows you to do this:


 struct get_b{
   B &operator()(A const &a){
     assert(a.b); return *a.b;
   }
 };

 list<A,member_object_hook<A,list_base_hook<>,get_b> > mylist;

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3489>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC