
Nicolas Rannou escribió:
Thanks, that is what I was suspecting.
Is there already something in boost to do what I intend to do? If not, which strategy would you recommend to by pass this issue? I got some ideas but nothing straight forward and I would like it to be as efficient as possible.
Thanks again,
Nicolas
In this particular case, you can do the following: Iterator it2 = m_Container.get< CollectionID >().lower_bound( 30 ); while( it2!=m_Container.get< CollectionID >().end() && it2->CollectionID==30) { 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); } else ++it2; } I haven't compiled it, but I think it should work. Two notes about the code: 1. Note that in the invocation to replace() we do a post-increment of it2, so that it2 points to the following element before the current one is replaced and, consequently, moved to a new position. 2. The while condition of the loop has changed: as a result of replacements, it could be the case that modified elements get between the range of elements with CollectionID==30 and it3, so checking for it2!=it3 is not safe. HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo. This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at. http://www.tid.es/ES/PAGINAS/disclaimer.aspx