Boost C++ Libraries: Ticket #5014: stride doesn't end iteration properly https://svn.boost.org/trac10/ticket/5014 <p> The code </p> <div class="wiki-code"><div class="code"><pre> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">v</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">push_back</span><span class="p">(</span> <span class="n">v</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">irange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">)</span> <span class="p">);</span> <span class="n">boost</span><span class="o">::</span><span class="n">copy</span><span class="p">(</span> <span class="n">v</span> <span class="o">|</span> <span class="n">boost</span><span class="o">::</span><span class="n">adaptors</span><span class="o">::</span><span class="n">strided</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">ostream_iterator</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="p">,</span> <span class="s">&quot; &quot;</span><span class="p">));</span> </pre></div></div><p> prints "0 4 8 12 16 20 24" instead of "0 4 8 12 16 20 24 28". </p> <p> See the discussion for similar cases: <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/211955"><span class="icon">​</span>http://thread.gmane.org/gmane.comp.lib.boost.devel/211955</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5014 Trac 1.4.3 Neil Groves Thu, 23 Dec 2010 00:17:57 GMT <link>https://svn.boost.org/trac10/ticket/5014#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5014#comment:1</guid> <description> <p> The requirement for the strided adaptor were overly severe. It required boost::size(rng) % stride_size == 0. </p> <p> I have modified the implementation of boost::size(rng) to enable modification of the strided_range constructors. This means that the strided_size no longer needs to be &lt;= boost::size(rng), and that rng may now be a model of the <a class="missing wiki">SinglePassRangeConcept</a> or better if the expression boost::size(rng) is also valid. </p> <p> This has been committed to the trunk. The regression tests shall be monitored before merging to the release branch. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Thu, 23 Dec 2010 08:40:02 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/5014#comment:2 https://svn.boost.org/trac10/ticket/5014#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.46.0</span> </li> </ul> <p> Resolved and passing regression tests. </p> Ticket mimomorin@… Fri, 24 Dec 2010 02:14:30 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/5014#comment:3 https://svn.boost.org/trac10/ticket/5014#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> The above code still prints "0 4 8 12 16 20 24" instead of "0 4 8 12 16 20 24 28". This is because, when constructing <code>strided_range</code>, the end iterator of an input range should advance forward rather than backward. The regression test (libs/range/test/adaptor_test/strided.cpp) passes because a similar thing happens when populating <code>reference</code> in <code>strided_test_impl</code>. </p> <p> Please see: <a class="ext-link" href="http://article.gmane.org/gmane.comp.lib.boost.devel/211975"><span class="icon">​</span>http://article.gmane.org/gmane.comp.lib.boost.devel/211975</a> (The codes in the mail assumes stride is greater than zero...) </p> Ticket Neil Groves Fri, 24 Dec 2010 15:07:06 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5014#comment:4 https://svn.boost.org/trac10/ticket/5014#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I confirm that I made a design error yesterday while making the change to the strided adaptor. The code I committed yesterday did not support <a class="missing wiki">ForwardRange</a> or <a class="missing wiki">SinglePassRange</a> concepts. Additionally it did not perform as we wanted. It was setting the last iterator in the range to be the last valid iterator on a stride boundary. </p> <p> To correct this I have added offset and max_offset information into the strided_iterator. This is required so that we can use the offset to go past the end of the range while avoiding advancing the underlying iterator beyond valid values. This change additionally corrects a defect with interoperability of strided iterators. </p> Ticket mimomorin@… Tue, 11 Jan 2011 06:42:00 GMT <link>https://svn.boost.org/trac10/ticket/5014#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5014#comment:5</guid> <description> <p> At line 12 of <code>libs/range/test/adaptor_test/strided.cpp</code>, could you change "Michel Morin" to "Maxim Yanchenko"? I believe Maxim should be credited there. Sorry for bothering you and thanks in advance. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Thu, 20 Aug 2015 11:47:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5014#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5014#comment:6</guid> <description> <blockquote class="citation"> <p> At line 12 of <code>libs/range/test/adaptor_test/strided.cpp</code>, could you change "Michel Morin" to "Maxim Yanchenko"? </p> </blockquote> <p> I just made a <a class="ext-link" href="https://github.com/boostorg/range/pull/35"><span class="icon">​</span>PR</a> on github. </p> </description> <category>Ticket</category> </item> </channel> </rss>