Boost logo

Boost Users :

Subject: Re: [Boost-users] Question on boost multi-index container erase method
From: joaquin_at_[hidden]
Date: 2008-10-01 01:56:16


Ramesh escribió:
> Hello Joaquin,
>
> I am trying to erase a record in the container based on keys - in my
> case both the keys are ordered and unique and I need to have ways to
> delete records based on either of the keys.
>
> I tried to erase an element based on key2 & I got the following error:
>
> "error: no matching function for call to 'boost::multi_index
> ....<Error runs for more than a page>
>
> :erase(boost::multi_index::detail::index_iterator
> <boost::multi_index::detail::ordered_index_node<boost::multi_index::detail
> ::index_node_base<MyMap> > >&)'
>
> [...]
> tMapDef::index_iterator<key2>::type it =
> key2_index.find(param_key2);
> [...]
> tMapDef::size_type status = MyContainer.erase(it);
>

You're retrieving a key2-index iterator and trying to use it on
key1-index. Replace your
last line with

        tMapDef::size_type status = key2_index.erase(it);

OK now?

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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