Boost C++ Libraries: Ticket #10646: polygon::iterator_compact_to_points returns wrong equality for the (last & penultimate) iterators https://svn.boost.org/trac10/ticket/10646 <p> <em>iterator_compact_to_points</em> is the part of <em>polygon_90</em> concept. </p> <p> <em>polygon_90_data</em> class exposes 2 iterators: <em>compact_iterator_type</em> and <em>iterator_type</em>. <em>iterator_type</em> extracts the complete point on-the-fly. And for the penultimate iterator it makes the wromg comparison with the last iterator. </p> <p> The reason of this bug is the specific implementation of operator++(). This is the same in boost versions 1.49 .. 1.56. </p> <p> At the moment I can propose the following workaround: </p> <pre class="wiki">typedef gtl::polygon_90_data&lt;int&gt; Polygon90; typedef gtl::polygon_traits_90&lt;Polygon90&gt;::point_type Point; typedef Polygon90::iterator_type Polygon90Iterator; bool equalIterators(const Polygon90Iterator&amp; left, const Polygon90Iterator&amp; right) { if (left == right) { return ((*left) == (*right)); } else { return false; } } </pre><p> The implementation of operator++() [taken from boost sources]: </p> <pre class="wiki">inline iterator_compact_to_points&amp; operator++() { iterator_type prev_iter = iter_; ++iter_; if(iter_ == iter_end_) { if(x(pt_) != firstX_) { iter_ = prev_iter; // this line produces the issue x(pt_, firstX_); } // it changes the cached point, but rolls back the iterator } else { set(pt_, orient_, *iter_); orient_.turn_90(); } return *this; } </pre><p> The testing code: </p> <pre class="wiki">#include &lt;boost/polygon/polygon.hpp&gt; namespace gtl = boost::polygon; #include &lt;vector&gt; typedef gtl::polygon_90_data&lt;int&gt; Polygon90; typedef gtl::polygon_traits_90&lt;Polygon90&gt;::point_type Point; typedef Polygon90::iterator_type Polygon90Iterator; std::vector&lt;Point&gt; polygonData; polygonData.push_back(Point(15, 07)); // 1 polygonData.push_back(Point(20, 07)); // 2 polygonData.push_back(Point(20, 05)); // 3 polygonData.push_back(Point(16, 05)); // 4 polygonData.push_back(Point(16, 01)); // 5 polygonData.push_back(Point(01, 01)); // 6 polygonData.push_back(Point(01, 06)); // 7 polygonData.push_back(Point(03, 06)); // 8 polygonData.push_back(Point(03, 10)); // 9 polygonData.push_back(Point(05, 10)); // 10 Polygon90 polygon90; polygon90.set(polygonData.begin(), polygonData.end()); Polygon90Iterator it = polygon90.begin(); for (int i = 0; i &lt; 8; i++) { it++; } Polygon90Iterator it_9th = it; it++; // this one points to 10th element bool bug = (it == it_9th); </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10646 Trac 1.4.3 Andrii Sydorchuk Wed, 12 Nov 2014 22:07:06 GMT owner changed https://svn.boost.org/trac10/ticket/10646#comment:1 https://svn.boost.org/trac10/ticket/10646#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Lucanus Simonson</span> to <span class="trac-author">Andrii Sydorchuk</span> </li> </ul> Ticket Andrii Sydorchuk Wed, 01 Apr 2015 01:01:15 GMT <link>https://svn.boost.org/trac10/ticket/10646#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10646#comment:2</guid> <description> <p> Hi Vadim, </p> <p> Thank you for your report! The fix and tests were merged into develop and master branches. The fix will be merged into 1.58 release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrii Sydorchuk</dc:creator> <pubDate>Wed, 01 Apr 2015 01:01:44 GMT</pubDate> <title>status, version changed; resolution set https://svn.boost.org/trac10/ticket/10646#comment:3 https://svn.boost.org/trac10/ticket/10646#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.49.0</span> → <span class="trac-field-new">Boost 1.58.0</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket vadim.sukhorukov@… Sat, 26 Mar 2016 12:39:04 GMT <link>https://svn.boost.org/trac10/ticket/10646#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10646#comment:4</guid> <description> <p> It is nit fixed in Boost 1.58.0 and even in Boost 1.60.0. The reported problem code is not changed. If you have a fix, please commit it to the repository. </p> </description> <category>Ticket</category> </item> </channel> </rss>