Original Post
Hi, I have a piece of code looking like : And it seems to work when I debug step by step. But the second time, I have an exception because my first element is completely screwd up :/ Is it impossible to swap 2 elements using iterators ? (I have solved the problem using [] operator, it works fine. But I'd like to use iterators)
std::vector<SSomeStructure> list;
// ...
for (iter = list.begin(); iter != list.end(); iter++)
{
bool b = (*iter).ptrToSomeClass->aMethod();
if (b)
{
// then I want to make the current element the first one of the array
SSomeStructure aStructure = *(list.begin());
*(list.begin()) = *iter;
*iter = aStructure;
}
}