Created on 2017-02-04.00:00:00 last changed 72 months ago
[ 2018-11-30, Jonathan comments, recommending NAD ]
Jonathan suggested NAD, because the proposed "just use increment when n==1" optimization can be done in std::next (and/or std::advance, and/or complicated iterators like deque::iterator) without adding an overload. Billy said the overload would avoid metaprogramming costs for dispatching to the right std::advance, and help in non-optimized builds. Zhihao said the overload would make it clear to users that the n==1 case is optimized (Jonathan thinks this is irrelevant as there's no requirement that we tell users what we optimize).
[ 2017-03-04, Kona ]
Set priority to 3. Alisdair to provide wording.
It seems that std::next is missing an optimization opportunity when taking a single parameter. The standard mandates that std::next shall call std::advance on the passed iterator and return it. For random-access iterators, it means that operator+= will be called on the iterator. However, if a single-argument overload was added to std::next, it could call ++it directly instead of std::advance(it, 1), which means that operator++ would be called instead of operator+=. This might make a small performance difference for complicated iterators such as std::deque's ones, where operator++ has a simpler logic than operator+=.
An equivalent optimization could be allowed by adding a single-argument overload to std::prev too.History | |||
---|---|---|---|
Date | User | Action | Args |
2018-12-01 15:27:06 | admin | set | messages: + msg10241 |
2017-03-14 03:14:09 | admin | set | messages: + msg9115 |
2017-03-14 03:14:09 | admin | set | status: new -> open |
2017-02-04 00:00:00 | admin | create |