Boost logo

Boost Users :

From: Moshe Matitya (Moshe.Matitya_at_[hidden])
Date: 2007-11-05 10:21:41


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net