Re: [Boost-bugs] [Boost C++ Libraries] #11801: Recursive modify in multi_index sometimes does not update index correctly

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11801: Recursive modify in multi_index sometimes does not update index correctly
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-23 06:51:26


#11801: Recursive modify in multi_index sometimes does not update index correctly
-------------------------------------+-------------------------------------
  Reporter: Valentyn Shtronda | Owner: joaquin
  <valiko.ua@…> | Status: closed
      Type: Bugs | Component: multi_index
 Milestone: To Be Determined | Severity: Problem
   Version: Boost 1.59.0 | Keywords: multi_index
Resolution: invalid | multi_index_container recursive
                                     | modify
-------------------------------------+-------------------------------------

Comment (by joaquin):

 ''Modification of key fields in `e` makes corresponding indices
 temporarily broken, until `modify()` returns. If you need to restore them
 sooner than `modify()` returns (for example, for recursive calls to
 `modify()`) wrap modification of key fields in its own call to
 `modify()`.''

 Not good :-) for a number of reasons (legalese follows):
 * There is no notion of "key field" in the library. The only concept
 defined is `KeyExtractor` which is more general as it doesn't relate to
 any specific data member (it can be, say, calculated, or made dependent on
 info indirectly associated to the element). Of course there is an
 intuitive understanding of what data members contribute to index
 invariants, but this is nowhere to be found in the reference docs.
 * "If you need to restore [the indices] sooner[...]": why should I need to
 restore them? It is not up to the user to figure it out, but to the
 reference to state the conditions in which the need arises.

 Moreover, you can't really assume that ''any'' part of the container
 interface is usable once you modify the element. For instance, in
 [http://www.boost.org/libs/multi_index/doc/tutorial/debug.html#invariant_check
 invariant-checking mode] any non-const member function will assert if
 there's some broken index, no matter which index you're actually using.
 Even allowing `mod(e)` to use only const member functions after
 modification limits my implementation leeway in the future.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11801#comment:10>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC