25 May, 2012, Baiou wrote in the 1st comment:
Votes: 0
Trying to loop through my list of connections and close ones that fail. Returns an error whenever I disconnect a connection with "Vector Not Incrementable". Any Ideas?

std::vector<SCARLETONLINE_CONNECTION_DESC>::iterator itr;

for( itr = connections_.begin(); itr != connections_.end(); ++itr ){

if( FD_ISSET( itr->iSocket, &readfds ) ){
// Handle Input
} else if( bytes == -1 )
perror( "::recv::" );
else {

_ShutdownSocket( &itr->iSocket );
_CloseSocket( &itr->iSocket );

itr = connections_.erase( itr );

}

}

}
26 May, 2012, Baiou wrote in the 2nd comment:
Votes: 0
Yup, can't figure this one out.
27 May, 2012, kiasyn wrote in the 3rd comment:
Votes: 0
Read this thread and see if it helps:
http://www.velocityreviews.com/forums/t2...

I think your problem is erasing the iterator while iterating
27 May, 2012, Tyche wrote in the 4th comment:
Votes: 0
One problem I see is that you increment the iterator after erase(), which isn't right because it should point to the next item after erase.
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> v;
for (int j=0;j<15;j++) v.push_back(j);
vector<int>::iterator i;
for( i = v.begin(); i != v.end();)
if (*i % 2) v.erase(i);
else i++;
for(i=v.begin();i!=v.end();i++) cout << *i << endl;
return 0;
}
0.0/4