how to detach elements from a boost::intrusive set container

1.2k views Asked by At

I am trying to detach elements from a boost::intrusive set and getting a assertion failure. when i delete the element after detaching it from the container.

The class derives from set_base_hook.

class fileXfer : public set_base_hook > 70 {

I am using "erase" function to detach the object from the container. when i try to delete the object i get assertion failure. The assertion failure is happening below at the following location.

/usr/local/include/boost/intrusive/detail/utilities.hpp:344: void boost::intrusive::detail::destructor_impl(Hook&, boost::intrusive::detail::link_dispatch<(boost::intrusive::link_mode_type)1u>) [with Hook = boost::intrusive::detail::generic_hook, boost::intrusive::default_tag, (boost::intrusive::link_mode_type)1u, 3>]: Assertion `!hook.is_linked()' failed. Aborted (core dumped)

when i looked at the location of the error i saw this command.

341 { //If this assertion raises, you might have destroyed an object 342 //while it was still inserted in a container that is alive. 343 //If so, remove the object from the container before destroying it. 344 (void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked()); 345 }

pls advise

1

There are 1 answers

0
Ravikumar Tulugu On BEST ANSWER

i got this solved after much googling. erase(Classname::s_iterator_to(value)) should be used instead of "erase(value)".