Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_index] Problem of scope with the replace in static data structure
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2009-02-12 14:44:17


Rodrigo Dias Ferreira wrote:
>
> Hi Joaquim,
>
> I saw what you meant, and I have changed...
> But still if I use the same graph_h, still I got the same problem:
> Here it is my solution for the Graph constructor:
> Graph(const Graph &g) : _rangeBegin(g._rangeBegin),
> _rangeEnd(g._rangeEnd),
> _nodeRep(g._nodeRep), _nodeNameRep(g._nodeNameRep),
> _localPropRep(g._localPropRep),
> _globalPropRep(g._globalPropRep){
> //_nodeRep::_uniqueName* Initialization
> pair<nodeMapIt,nodeMapIt> rangeNodeIt;
> nodeMapIt tmpNodeIt;
> rangeNodeIt.first = g._nodeRep.begin();
> rangeNodeIt.second = g._nodeRep.end();
>
> while (rangeNodeIt.first != rangeNodeIt.second){
> _nodeRep.insert(nodeMap(
> &*(_nodeNameRep.find(rangeNodeIt.first->_uniqueName->_name)),
> rangeNodeIt.first->_timestamp, rangeNodeIt.first->_node));
> ++rangeNodeIt.first;
> }
>
> }
>

I'm still seeing a problem here: _noderep is populated twice:

        Graph(const Graph &g) : _rangeBegin(g._rangeBegin), _rangeEnd(g._rangeEnd),
                _nodeRep(g._nodeRep), // _nodeRep is populated here
                ...{
                ...
                while (rangeNodeIt.first != rangeNodeIt.second){
                        _nodeRep.insert(...); // and here again
                }
        }

Shouldn't you be omitting the first population? Besides, I
recommend you turn on Boost.MultiIndex safe-mode on as
commented on my previous post and see whether some
assertion triggers.

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

-- 
View this message in context: http://www.nabble.com/Re%3A--multi_index--Problem-of-scope-with-the-replace-in-static-data-structure-tp21950412p21983479.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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