Doesn't std::map.erase returns iterator?
I have a project that compiles in Microsoft Visual C++ .net 2003. I'm
trying to compile it in Dev C++ to try to get some optimization. However, I
get an error on this code which seems to tell me it can't assign the
iterator.:
typedef std::map<unsigned int, CEffect*> BeamEffectsType;
// ...
// Update ALL the -On-The-Fly- or Fired 'Beams' to NEW positions.
for ( BeamEffectsType::iterator it = Client.BeamEffects.begin(); it !=
Client.BeamEffects.end(); )
{
if ( !(*it).second->Update() )
{
delete (*it).second;
it = Client.BeamEffects.erase(it);
}
else
++it;
}
Where BeamEffects in Client is a BeamEffectsType.
Abyssal.cpp:2313: error: no match for 'operator=' in 'it =
(((BeamEffectsType*)(&Client)) + 208324u)->std::map<_Key, _Tp, _Compare,
_Alloc>::erase [with _Key = unsigned int, _Tp = CEffect*, _Compare =
std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned
int, CEffect*> >](it)'
e:/Dev-Cpp/include/c++/3.4.2/bits/stl_tree.h:152: note: candidates are:
std::_Rb_tree_iterator<std::pair<const unsigned int, CEffect*> >&
std::_Rb_tree_iterator<std::pair<const unsigned int, CEffect*>
>::operator=(const std::_Rb_tree_iterator<std::pair<const unsigned int,
CEffect*> >&)
The line 2313 being
it = Client.BeamEffects.erase(it);
It shows the same error in another part of the code where I'm doing the same
thing with the BeamEffects. Is MSVC++ returning an iterator for a std::map
as an extension, is DevC++ not returning an iterator when it should, or am I
doing something else wrong that I can't tell?
Thanks.
--
Jim Langston
tazmaster@rocketmail.com