Remove a given item from a boost::intrusive::list

Viewed 800

I have a pointer to an object that is guaranteed to be in a boost::intrusive::list. Given that pointer/object, can I remove it from the list ?

The following illustrates what I'm trying to do:

#include <boost/intrusive/list.hpp>

struct MyStruct : public boost::intrusive::list_base_hook<>  {
    int i;
    MyStruct(const MyStruct &) = delete;
    MyStruct& operator= (const MyStruct &) = delete;
    MyStruct(int val) : i(val) {}
};

void test()
{
    boost::intrusive::list<MyStruct> l;
    MyStruct a(1);

    l.push_back(a);

    MyStruct* p = &a;
    //At this point I have a pointer to an item that is in the list,
    //Given this pointer, is there any way I can remove that item from the list ? 
}
1 Answers
Related