This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [libstdc++/61347] std::distance(list.first(),list.end()) in O(1)
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Tue, 14 Apr 2015 10:32:09 +0100
- Subject: Re: [libstdc++/61347] std::distance(list.first(),list.end()) in O(1)
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 11 dot 1504131033550 dot 13447 at stedding dot saclay dot inria dot fr> <20150413134025 dot GI9755 at redhat dot com> <alpine dot DEB dot 2 dot 11 dot 1504131549210 dot 13447 at stedding dot saclay dot inria dot fr> <20150413151057 dot GK9755 at redhat dot com> <alpine dot DEB dot 2 dot 02 dot 1504140951460 dot 27632 at stedding dot saclay dot inria dot fr>
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.