Boost C++ Libraries: Ticket #923: Request extended next() for utility lib https://svn.boost.org/trac10/ticket/923 <pre class="wiki">The standard library's "advance(it, n)" algorithm is often awkward to use because it takes the "it" argument by reference. At times I want to access the n-th element in a sequence, where I don't know if the iterator is random-access or not (e.g., a generic algorithm where the iterator type is only required to be a model of ForwardIterator) and the O(n) time for advance with a non-random-access iterator is a negligible contribution to the overall runtime of the algorithm. Using advance, I have to write something like this: IteratorType it = foo.begin(); advance(it, n); f(*it); If the iterator type is complicated, the above is rather awkward. I would like to instead write f(*next(it, n)); where the overloaded next() is defined something like this: template &lt;typename ForwardIterator, typename Distance&gt; ForwardIterator next(ForwardIterator it, Distance n) { advance(it, n); return it; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/923 Trac 1.4.3 david_abrahams Thu, 29 May 2003 17:03:45 GMT <link>https://svn.boost.org/trac10/ticket/923#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/923#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=52572 It's a good idea. I suggest posting code/doc/test patches. You should also do the same thing for prior. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>biochimia</dc:creator> <pubDate>Sat, 04 Feb 2006 17:26:41 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/923#comment:2 https://svn.boost.org/trac10/ticket/923#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> <pre class="wiki">Logged In: YES user_id=840777 This feature was committed to CVS on 23-Dec-2003 (boost/next_prior.hpp) and is available since Boost 1.31. Closing as accepted. </pre> Ticket