This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Optimize std::advance for single increments
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 5 Jun 2017 12:47:56 +0200 (CEST)
- Subject: Re: [PATCH] Optimize std::advance for single increments
- Authentication-results: sourceware.org; auth=none
- References: <20170605104350.GA17860@redhat.com>
- Reply-to: libstdc++ at gcc dot gnu dot org
On Mon, 5 Jun 2017, Jonathan Wakely wrote:
LWG 2931 suggests a new overload of std::next for the default n==1
case, because it can be simpler for some random access iterators to do
++i than i += 1, e.g. for std::deque::iterator.
I've suggested we close that issue as NAD, because we don't need a new
overload to do that, and here's the proof. This performs the same
optimisation when the argument to __advance<RandomAccessIterator> is
known at compile-time to be +1 or -1, as is the case when called from
std::next(i) or std::prev(i).
Do you want to optimize the case __n == 0 as well? ;-)