Boost C++ Libraries: Ticket #1860: zip_iterator::value_type should not be reference https://svn.boost.org/trac10/ticket/1860 <p> hi, defining zip_iterator::value_type in the boost.iterator library to be the same as the reference type breaks some mutating algorithms on zip_iterators. for example sort: </p> <pre class="wiki">template&lt;class Array1,class Array2&gt; void array_multisort(Array1&amp; array1, Array2&amp; array2) { using namespace boost; std::sort(make_zip_iterator(make_tuple(array1.begin(), array2.begin())), make_zip_iterator(make_tuple(array1.end(), array2.end()))); } </pre><p> won't work as expected. Patching zip_iterator to provide a more natural value_type makes the above code work as intended. The patch is attached to this message. </p> <p> mfg thomas </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1860 Trac 1.4.3 anonymous Thu, 24 Apr 2008 18:39:47 GMT attachment set https://svn.boost.org/trac10/ticket/1860 https://svn.boost.org/trac10/ticket/1860 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">zip_iterator.diff</span> </li> </ul> Ticket Steven Watanabe Fri, 21 Aug 2009 19:33:16 GMT <link>https://svn.boost.org/trac10/ticket/1860#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1860#comment:1</guid> <description> <p> This looks like a duplicate of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/973" title="#973: Bugs: zip_iterator has value_type == reference (new)">#973</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Mathias Gaunard</dc:creator> <pubDate>Fri, 28 Aug 2009 14:29:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1860#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1860#comment:2</guid> <description> <p> Is there any reason not to merge this patch? zip_iterator compiles the above code but produces erroneous output, that's a pretty important bug. </p> <p> If there is a problem with this patch, please let me know what needs to be improved. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Sat, 28 Nov 2009 18:23:46 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/1860#comment:3 https://svn.boost.org/trac10/ticket/1860#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Dave Abrahams</span> to <span class="trac-author">Mathias Gaunard</span> </li> </ul> <p> One reason is that I don't have a testcase that is actually reliable. You see, <code>zip_iterator</code> <em>can't</em> be a legit C++03 Forward Iterator, since its <code>reference</code> type is not a real reference. Therefore, the standard library has a right to refuse to compile the example you gave even without the patch. It may work on your installation and legitimately break somewhere else. </p> <p> So, if you could build a testcase that doesn't rely on strict <code>Forward Iterator</code> conformance, but instead captures the assumptions that your <code>std::sort</code> implementation is making, that make this work, I'd be more than happy to accept the patch as a QOI improvement. </p> <p> A smaller issue is the definition of <code>iterator_value_type</code> is redundant with <code>iterator_value</code> in <code>&lt;boost/iterator/iterator_traits.hpp&gt;</code> </p> <p> Thanks for your efforts and patience on this one. </p> Ticket dtrebbien@… Sun, 28 Nov 2010 00:11:04 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1860#comment:4 https://svn.boost.org/trac10/ticket/1860#comment:4 <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">duplicate</span> </li> </ul> Ticket