Boost logo

Boost :

Subject: Re: [boost] Is Boost.Range broken?
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-23 01:49:55

on Sat Nov 22 2008, "Andrey Semashev" <> wrote:

> The documentation of the iterator_range states for several functions, such
> as size() and operator[], that these functions depend on the iterator
> nature. I believe, empty() could just do the same - rely on the ability to
> compare iterators, even default-initialized ones. Of course, this should be
> clearly stated in the docs.

I think that's the right approach. In other words, provided that
default-initialized instances of Iter can be compared, and compare
equal, the empty() member of a default-initialized iterator_range<Iter>
produces defined behavior.

Frankly, you don't even need to be that explicit: just write the
semantics of empty as

      begin(r) == end(r)

and you're done. Of course, more explicit documentation could be helpful.

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at