Re: [Boost-users] [iterators][range] size compile failure in 1.35
9 Jun
2008
9 Jun
'08
6:40 p.m.
Jeff Flinn skrev:
David Abrahams wrote:
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?
boost::distance(r) could also work. I did it as part of the general clean-up of the range lib. size() is expected to be O(1) by users, distance() is not. -Thorsten
6001
Age (days ago)
6001
Last active (days ago)
0 comments
1 participants
participants (1)
-
Thorsten Ottosen