|
Boost Users : |
Subject: Re: [Boost-users] Question on boost multi-index container erase method
From: Ramesh (rramesh1_at_[hidden])
Date: 2008-10-08 21:03:14
Apologies for a late response, i was on travel.
Thank you very much. Works perfectly. I checked the prototype for
erase - it returns a count of objects that it erases, in my case -
after I made the code change as you suggested, compiler flagged an
error saying couldnt convert iterator to size_t type.
error: cannot convert
'boost::multi_index::detail::index_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<<MyMap>>
> >' to 'size_t' in initialization
Is the datatype of status wrong?
Thanks
Ramesh
On Tue, Sep 30, 2008 at 10:56 PM, <joaquin_at_[hidden]> wrote:
> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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