5 Nov
2007
5 Nov
'07
3:21 p.m.
LoadCom wrote:
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.
Why is it so "obviously different"? Just like NULL is a special pointer value denoting a pointer that does not reference a valid object, so too the last iterator of a given range [first, last) is an iterator that does not reference any object within the range. Why not do this: list<int>::iterator it_NULL = alist.end(); list<int>::iterator it_beg = alist.begin(); // ... std::cout << "(it_NULL == it_beg) " << (it_NULL == it_beg) << endl; Moshe