Boost Users :
Subject: Re: [Boost-users] [range] iterator_range::size() requires a random access iterator?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-10-15 21:05:15
Adam Merz wrote:
> Why does boost::iterator_range::size() require a random access iterator? The
> implementation is 'return m_End - m_Begin;' -- if this were changed to 'return
> std::distance(m_Begin, m_End);' then size() would work with any iterator type.
> This strikes me as an arbitrary limitation, or at the least a leaky abstraction.
> Is there a rationale here?
This is intentional. size is always constant time.
If you want distance, call boost::distance.
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