Boost logo

Boost Users :

Subject: [Boost-users] [MultiIndex] Iterator validity when modifying equal_range keys
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2011-09-02 11:59:27


Hello *,

reading this page states only that iterator validity is preserved for hashed
indices. I have a multi-index container with ordered_non_unique entries.

Is it safe to find a matching range and modify the keys there?

Here an example:

    entry_data& entries = indexed; //get the view to the MI-Container

    for(iterator_range<entry_data::iterator> r
          = entries.equal_range(boost::make_tuple(false))
        ; !r.empty()
        ; r.advance_begin(1)
       )
    {
      index_data d = r.front();
      d.masked = true;
      entries.replace(r.begin(), d);
    }

Here updated d.masked field is a first member of the composite key. What
happens if I do the update as shown upon?

Would it be more efficient to iterate backwards and do the update, since
than all the elements will not be rearranged?

Is there also any way to use modify_key with composite index or are
composite index key extractors always read-only?

With Kind Regards,
Ovanes



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