For one thing, you can simply define operator == for any weak_ptr. I am sure that the reason is that this is not implemented, perhaps it will bite you at a later moment.
template <typename T>
bool operator == (const std::tr1::weak_ptr<T>& a, const std::tr1::weak_ptr<T>& b)
{
return a.lock() == b.lock();
}
... and you can just call remove () as usual. I think this is a little extreme.
remove_if(), *, :
struct EqPredicate
{
const boost::weak_ptr<Item>& theItem;
EqPredicate(const boost::weak_ptr<Item>& item) : theItem(item)
{
}
bool operator () (const boost::weak_ptr<Item>& p) const
{
return p.lock() == theItem.lock();
}
};
:
mylist.remove_if(EqPredicate(pItem));
, EqPredicate, . , , , , Item.
, weak_ptrs , .
* bind . Remove() , , .