Hi all,
I'm pretty new in boost and I am experimenting an issue I can't
understand.
It looks like the usage of "replace()" modifies the iterator I am
iterating on:
Here is a simple example:
it iterates properly if I do:
Iterator it2, it3;
boost::tuples::tie(it2, it3) = m_Container.get<
CollectionID >().equal_range( 30 );
while( it2!= it3 )
{
int time = it2->TCoord;
if( time < 500 ) // we want to change the collection ID
in this case
{
Structure tempStructure(*it2);
tempStructure.CollectionID = 40;
//m_Container.get< CollectionID
>().replace(it2, tempStructure); comment this line
}
++it2;
}
whereas if I call "replace()" the iterator value changes to "it3"
then it exists the loop:
Iterator it2, it3;
boost::tuples::tie(it2, it3) = m_Container.get<
CollectionID >().equal_range( 30 );
while( it2!= it3 )
{
int time = it2->TCoord;
if( time < 500 ) // we want to change the collection ID
in this case
{
Structure tempStructure(*it2);
tempStructure.CollectionID = 40;
m_Container.get< CollectionID >().replace(it2,
tempStructure);
}
++it2;
}
the replace() method returns true.
I must be missing something but after reading the
documentation and some researches on the web I couldn't find
the answer.
Any help/explanation would be greatly
appreciated,
Thanks,
Nicolas