[libstdc++/61347] std::distance(list.first(),list.end()) in O(1)
Jonathan Wakely
jwakely@redhat.com
Tue Apr 14 09:32:00 GMT 2015
On 14/04/15 10:24 +0200, Marc Glisse wrote:
>On Mon, 13 Apr 2015, Jonathan Wakely wrote:
>
>>I don't have a preference, but I think the forward declarations should
>>work without problems. <list> includes bits/stl_iterator_base_funcs.h
>>so if the forward declarations didn't match the definitions for some
>>reason we'd know right away.
>
>Here is a new version that also passes the tests. I guess we will have
>plenty of time during stage1 to notice if it causes problems. We could
>probably move the new definitions of __distance to
>bits/stl_iterator_base_funcs.h, I don't have a clear preference.
Seems like a great start and we can improve it later if needed.
OK for trunk, thanks.
We should also look into applying the same optimisation for
__gnu_debug::list, as long as we don't lose the ability to detect
errors like std::distance(l1.begin(), l2.end()) where &l1 != &l2.
More information about the Libstdc++
mailing list