Re: iterator error
James Kanze wrote:
On Apr 6, 3:02 am, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
?????????? wrote:
windows xp, visual studio 2005
----------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<int, int>::iterator it = 0;
if( it != 0 ) //break point,
this is an run time error?
cout<<"ok!";
}
----------------------------------------------------------------------------------------------------------------------------------
why it can be assign "0", but can't compare with "0"?
The iterator type in 'map' is implementation-defined. What
it means to initialise it with (int)0 is implementation-defined.
Why operator != (int)0 doesn't work is (you guessed it!)
implementation-defined.
It's not even implementation-defined, it's undefined.
Is it explicitly undefined (as in dereferencing a null pointer)?
All I can see in the standard is that 'iterator' type in 'std::map'
is implementation-defined. Is it not conceivable that the type
might actually define comparison with 0?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask