|
Boost : |
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-06-06 21:21:53
On Fri, Jun 6, 2008 at 7:28 PM, Jeff Flinn
<TriumphSprint2000_at_[hidden]> wrote:
> David Abrahams wrote:
>> on Fri Jun 06 2008, Jeff Flinn <TriumphSprint2000-AT-hotmail.com> wrote:
>>
>>> I'm moving from 1.34.1 to 1.35.0
>>>
>>> The following compiles in 1.34.1 and fails in 1.35.0 on MSVC 8. Any
>>> thoughts on how to correct this?
>>
>> Jeff,
>>
>> in 1.35 I'm pretty sure that iterator_range<T>::size() only works when T
>> is a random access iterator, and filtered iterators are by necessity
>> bidirectional. I suggest you use
>>
>> std::distance(r.begin(), r.end())
>>
>> if you're willing to pay for O(N) execution.
>>
>
> Hmm, it looks like that's what iterator_range<T>::size() did in 1.34.1
> while 1.35 returns m_Begin - m_End. Any idea why this was done?
>
To guarantee that it will only compiles if it can be implemented
efficiently (i.e. only for random access iterators).
Looking at the docs, it seems that boost range also provides a range
based distance that will work for all iterators but doesn't guarantee
O(1) complexity.
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk