Boost logo

Boost :

Subject: Re: [boost] [range] [1.40] iterator_range::size broken for non-random access iterators
From: Eric Niebler (eric_at_[hidden])
Date: 2009-08-21 16:21:16


Ryan Gallagher wrote:
> We were just upgrading from 1.34.1 to 1.39.0 and I ran into this
> issue which I note is still in the trunk (and I would assume the
> 1.40 candidate).
>
> The definition of iterator_range::size is using operator- where
> it should be using std::distance as it did in boost 1.34 days:
>
<snip>
> I'm not sure why it would have changed but it's no longer working with
> bi-directional iterators, etc. Can we put back the old version?
> Can we get this fixed for 1.40? Thanks,

This change is intentional. We decided that iterator_range::size should
be O(1), or else it shouldn't compile.

To get the old behavior, you can use boost::distance in
boost/range/distance.hpp.

HTH,

-- 
Eric Niebler
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