Boost logo

Boost Users :

From: Szczepan Ho³yszewski (rulatir_at_[hidden])
Date: 2008-02-26 00:02:11


I have a pointer to an object that is in a ptr_list, and I want to "detach"
the object from the list without deleting it.

Problem: ptr_list::release() wants an iterator, not a pointer.

A naive attempt at std::finding the iterator fails because ptr_list's
indirection kicks in and std::find ends up wanting to compare values instead
of pointers. Luckily my objects aren't equality comparable so I get a compile
error instead of an elusive bug. As a workaround I just walk the list with
BOOST_FOREACH() but it feels kludgy.

Is there a "designed" way to feed a ptr_list an element pointer and milk the
corresponding iterator?

Is there a direct way do detach an item from ptr_list without deleting it?

Did I overlook something obvious?

Thanks in advance,
Szczepan Holyszewski


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net