2
boost :: intrusive :: list内にあることが保証されているオブジェクトへのポインタがあります。そのポインタ/オブジェクトを指定すると、リストから削除できますか?boost :: intrusive :: listから指定された項目を削除します。
以下は、私が何をしようとしている示しています
#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 ?
}
_「価値で項目を削除します)(削除思えるように、これは、失敗しました」_あなたはそれに価値を与えました。 '* p'はポインタではありません。それが指摘されているものです。 'MyStruct * p =&a;' –
私はちょうど私が侵入リストにリンクしたノードを削除したいのですが、そうする方法がありますか?項目がリストにコピーされないので、リストに追加された元のノードがあれば、項目を削除することができるはずです。 – binary01
あなたが簡単に作成できる述語があるようです。http://www.boost.org/doc/libs/1_35_0/doc/html/intrusive/erasing_and_disposing.html –