Hi, I'm not sure to understand the goal of your test iterator comparison but if it's to test a list emptiness why not just using alist.empty()? In my understanding a list iterator is not designed to be NULL. But the object it points to could be null and thus you should better test the object than the iterator. Hope it helps, ~Benoi^t LoadCom wrote:
Hello,
It's a question that perhaps has little to do with boost, but I guess the boosters must be able to help me. :-)
The question is: I want to have an iterator of a std::list type that denotes a NULL iterator, which means the iterator points to nothing, and is obviously different from list::end(), which points to the pass-the-end of a list.
I'm using the following code:
list<int> alist; alist.push_back(1);
list<int>::iterator it_NULL; // denotes a NULL iterator list<int>::iterator it_beg = alist.begin();
std::cout << boolalpha; std::cout << "(it_NULL == it_beg) " << (it_NULL == it_beg) << endl;
I got correct result under VS 2003, but under VS2005, I got an runtime error. The cause of the error seems to be I could not compare 2 iterators that don't belong to the same container.
I have looked up the C++ 98 standard, and there seems not to be such a restriction for 2 iterators of the same type in comparasion should belong to a same container.
What's wrong? Or any other alternative solution available? Thanks in advance for any help.
Max
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users