On 10.06.2009 15:45 Uhr, Wang Rui wrote:
It seems that the return value of erase() are different in Windows and
Unix/Linux. I've done some work in my previous projects like:
for ( DataMap::iterator itr=map.begin(); itr!=map.end(); )
{
DataMap::iterator old_itr = itr;
itr++;
map.erase( old_itr );
}
That's because "itr = map.erase(itr)" is not compilable with some gcc
versions.
I don't believe this is the problem. The 'it = container.erase(it)' construct
is correct.
However, in this case (from VPB):
for(TimeIteratorMap::iterator itr = _timeIteratorMap.begin();
itr != _timeIteratorMap.end();
++itr)
{
datasetMap.erase(itr->second);
}
the iterator 'itr' is for TimeIteratorMap whereas the erase is on 'datasetMap'
and
'datasetMap.erase(...)' would logically return a DatasetMap::iterator which (thankfully)
cannot be assigned to a TimeIteratorMap::iterator, not even under Windows.
Cheers,
/ulrich
2009/6/10 <[email protected] <mailto:[email protected]>>
I think the problem is also not using the iterator in the style that
the iterator algorithm was originally intended. I have used your
style as it hides the iterator declation when the for loop goes out
of scope, but I think the expected usage was more along the lines of:
{
iterator iter = map.begin();
while( iter != map.end() )
iter = map.erase( ... );
}
PhilT
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org