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" <andrey.semashev-AT-gmail.com> 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 http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk