Boost logo

Boost :

Subject: [boost] [range] [1.40] iterator_range::size broken for non-random access iterators
From: Ryan Gallagher (ryan.gallagher_at_[hidden])
Date: 2009-08-21 15:52:03


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:

"""
difference_type size() const
{
   BOOST_ASSERT( !is_singular() );
   return m_End - m_Begin;
}
"""

It used to be:

"""
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
                return std::distance<IteratorT>( m_Begin, m_End );
#else
                return std::distance( m_Begin, m_End );
#endif
"""

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,

-Ryan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk