AMDG Rodrigo Dias Ferreira wrote:
I am using the Boost.MultiIndex and I am facing a problem that I am try to resolving (debbuging) already about 20 hours... I think I get the problem isolated, but I don't know how to solve, and I don't know if this it is implemented. So I decided to make a example, it is a little big, but I put it as resumed as I could and post here in order to know if anyone could help me out.
I will try to explain briefly here, I will copy the main() code right under the explanation, but the whole code of the example is in the end of the e-mail (with the classes and functions) If you want you could try to run too see what is the problem that I am talking about.)
When I try to access an pair of iterators pair
that I stored inside a class (propertystream_h), somehow is changing to where the iterator points, I think it could be because the object which has originate (Graph) the index is created, stored in in a static index (which I call _graphRep) from the DynamicGraphs, passed to a handler (Graph_h), and then after the Graph goes out of scope it is destroyed. When the Graph_h._localGraph (copy of the iterator->Graph returned by the insertion in the _graphRep) access its member _globalProperties (which is an index containing the fields: {string _key, string _value, propertystream_h _props} from the struct globalPropSchema) through a iterator (let's call it: gpit), then it is fine. But then when I try to access through the gpit->_props._propRangeIt.first, the iterator of the propertystream_h (_propRangeIt.first), then the iterators, some how are messed up. ( -> in this example it points to last element, and then when I get next, never finds the end(). (sometimes it return some trash, sometimes I get segmentation fault). So I would like to know why it is messing with the iterator? And how could I solve this problem?
It would help if you put #if !defined(NDEBUG) #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE #endif at the top before #including any multi_index headers. The problem is that when you copy and destroy the graph, the iterators in _globalPropRep are left pointing into the old graph. In Christ, Steven Watanabe