Hi,
I have a problem compiling a project in Dev-C++ (MingW32). For some reason I can't assign an iterator from map::erase(iterator). My sources (MSDN) for map::erase(iterator) says that erase(iterator) returns an iterator... Does anyone know what I'm doing wrong?
bool TCPIPRedirectManager::poll(){
bool haveMsg = false;
for(map<ConnHandle, TCPIPRedirect*>::iterator it = openPorts.begin(); it != openPorts.end(); ){
if(it->second->poll()){
haveMsg = true;
}
else if(it->second->shouldClose()){
delete it->second; // close the port
it = openPorts.erase(it); // <-- ##THIS IS THE PROBLEM LINE##
continue; // go to top - don't inc iterator
}
it++;
}
return haveMsg;
}
The error message is shown here, the line it's talking about is the iterator assignment line.
In member function `bool TCPIPRedirectManager::poll()':
no match for 'operator=' in 'it = ((std::map<ConnHandle, TCPIPRedirect*, std::less<ConnHandle>, std::allocator<std::pair<const ConnHandle, TCPIPRedirect*> > >*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::erase [with _Key = ConnHandle, _Tp = TCPIPRedirect*, _Compare = std::less<ConnHandle>, _Alloc = std::allocator<std::pair<const ConnHandle, TCPIPRedirect*> >](it)'
note C:\Dev-Cpp\include\c++\3.4.2\bits\stl_tree.h:152 candidates are: std::_Rb_tree_iterator<std::pair<const ConnHandle, TCPIPRedirect*> >& std::_Rb_tree_iterator<std::pair<const ConnHandle, TCPIPRedirect*> >::operator=(const std::_Rb_tree_iterator<std::pair<const ConnHandle, TCPIPRedirect*> >&)