4

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

4

1 に答える 1

5

私は多くのグーグルの後でこれを解決しました。「erase(value)」の代わりにerase(Classname :: s_iterator_to(value))を使用する必要があります。

于 2012-06-01T05:41:00.550 に答える