Boost C++ Libraries: Ticket #973: zip_iterator has value_type == reference https://svn.boost.org/trac10/ticket/973 <p> That looks wrong to me. See <a class="ext-link" href="http://groups.google.com/group/comp.std.c++/browse_frm/thread/9c40ffc2f6394ca0/89ef062ddcb231e7"><span class="icon">​</span>http://groups.google.com/group/comp.std.c++/browse_frm/thread/9c40ffc2f6394ca0/89ef062ddcb231e7</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/973 Trac 1.4.3 Dave Abrahams Mon, 21 May 2007 04:28:55 GMT description changed; owner set https://svn.boost.org/trac10/ticket/973#comment:1 https://svn.boost.org/trac10/ticket/973#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Thomas Witt</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/973?action=diff&amp;version=1">diff</a>) </li> </ul> Ticket dtrebbien@… Sun, 28 Nov 2010 00:14:35 GMT <link>https://svn.boost.org/trac10/ticket/973#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:2</guid> <description> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1860" title="#1860: Bugs: zip_iterator::value_type should not be reference (closed: duplicate)">#1860</a> is a duplicate of this ticket. Please see that ticket for more information. </p> </description> <category>Ticket</category> </item> <item> <author>blackhc@…</author> <pubDate>Wed, 26 Sep 2012 12:47:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:3</guid> <description> <p> Is anything ever going to happen on this issue? I have the exact same problem as described in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1860" title="#1860: Bugs: zip_iterator::value_type should not be reference (closed: duplicate)">#1860</a> and a solution would be really helpful... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 12 Nov 2012 21:20:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:4</guid> <description> <p> Dave asked for a testcase. Here's one: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/iterator/zip_iterator.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/iterator/iterator_traits.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/assert.hpp&gt;</span><span class="cp"></span> <span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">It</span><span class="o">&gt;</span> <span class="kt">void</span> <span class="n">my_iter_swap</span><span class="p">(</span><span class="n">It</span> <span class="n">i1</span><span class="p">,</span> <span class="n">It</span> <span class="n">i2</span><span class="p">)</span> <span class="p">{</span> <span class="k">typename</span> <span class="n">boost</span><span class="o">::</span><span class="n">iterator_value</span><span class="o">&lt;</span><span class="n">It</span><span class="o">&gt;::</span><span class="n">type</span> <span class="n">tmp</span> <span class="o">=</span> <span class="o">*</span><span class="n">i1</span><span class="p">;</span> <span class="o">*</span><span class="n">i1</span> <span class="o">=</span> <span class="o">*</span><span class="n">i2</span><span class="p">;</span> <span class="o">*</span><span class="n">i2</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">;</span> <span class="p">}</span> <span class="kt">int</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">i</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="p">};</span> <span class="n">my_iter_swap</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">make_zip_iterator</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">0</span><span class="p">)),</span> <span class="n">boost</span><span class="o">::</span><span class="n">make_zip_iterator</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">make_tuple</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">)));</span> <span class="n">BOOST_ASSERT</span><span class="p">(</span><span class="n">i</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="n">i</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> And here's a patch against boost 1.52.0 that fixes it. I hereby place it in the public domain. </p> <pre class="wiki">351a352,362 &gt; // Metafunction to obtain the type of the tuple whose element types &gt; // are the value types of an iterator tuple. &gt; template&lt;typename IteratorTuple&gt; &gt; struct tuple_of_value_types &gt; : tuple_impl_specific::tuple_meta_transform&lt; &gt; IteratorTuple, &gt; iterator_value&lt;mpl::_1&gt; &gt; &gt; &gt; { &gt; }; &gt; 418c429,430 &lt; typedef reference value_type; --- &gt; typedef typename &gt; detail::tuple_of_value_types&lt;IteratorTuple&gt;::type value_type; </pre><p> Now, can we get this fixed? Pretty please? </p> </description> <category>Ticket</category> </item> <item> <author>Matthias Berndt <matthias_berndt@…></author> <pubDate>Mon, 12 Nov 2012 21:31:12 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/973#comment:5 https://svn.boost.org/trac10/ticket/973#comment:5 <ul> <li><strong>cc</strong> <span class="trac-author">matthias_berndt@…</span> added </li> </ul> Ticket Matthias Berndt <matthias_berndt@…> Wed, 21 Nov 2012 07:02:25 GMT <link>https://svn.boost.org/trac10/ticket/973#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:6</guid> <description> <p> OK, now what the hell is going on here? </p> <ul><li>this is an obvious and serious bug </li><li>the bug report is six years old </li><li>an obvious and trivial fix has been available for five years </li></ul><p> Just what is supposed to happen until anybody cares to commit the fix? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Wed, 21 Nov 2012 22:26:37 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/973#comment:7 https://svn.boost.org/trac10/ticket/973#comment:7 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Thomas Witt</span> to <span class="trac-author">jeffrey.hellrung</span> </li> </ul> Ticket Dave Abrahams Wed, 21 Nov 2012 23:39:10 GMT <link>https://svn.boost.org/trac10/ticket/973#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:8</guid> <description> <p> The current library maintainer wasn't assigned here so he hasn't seen your bump. I just fixed that. </p> </description> <category>Ticket</category> </item> <item> <author>Matthias Berndt <matthias_berndt@…></author> <pubDate>Sat, 01 Dec 2012 16:37:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/973#comment:8" title="Comment 8">dave</a>: </p> <blockquote class="citation"> <p> The current library maintainer wasn't assigned here so he hasn't seen your bump. I just fixed that. </p> </blockquote> <p> Uh, did you? In my world, a maintainer is somebody who maintains. Not committing a ready-made fix for a trivial, six-year-old bug is not what I'd call maintaining. </p> <p> Let me ask again: what is supposed to happen until anybody cares to commit this trivial patch? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sat, 01 Dec 2012 17:27:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:10</guid> <description> <p> A patch is not trivial just because it only changes a small amount of code. This is a significant change in the behavior of zip_iterator, and it can't just be applied blindly. At the very least, these questions need to be answered: </p> <ul><li>What <em>exactly</em> is the behavior supposed to be? This <strong>must</strong> be documented. </li><li>How does this behavior relate to the standard iterator requirements? The problem with this patch is that most use cases rely on fudging the requirements and hoping that the standard library doesn't notice. </li><li>What can the patch break? </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Sat, 01 Dec 2012 20:25:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:11</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/973#comment:9" title="Comment 9">Matthias Berndt &lt;matthias_berndt@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/973#comment:8" title="Comment 8">dave</a>: </p> <blockquote class="citation"> <p> The current library maintainer wasn't assigned here so he hasn't seen your bump. I just fixed that. </p> </blockquote> <p> Uh, did you? </p> </blockquote> <p> Uh, yes. </p> <blockquote class="citation"> <p> In my world, a maintainer is somebody who maintains. Not committing a ready-made fix for a trivial, six-year-old bug is not what I'd call maintaining. </p> </blockquote> <p> Even if this were trivial to apply (which it isn't for the reasons Steven cited) Jeffrey only took over maintainership this year. I'm trying to get your concern addressed, so please try to be a little gracious about it. </p> </description> <category>Ticket</category> </item> <item> <author>Matthias Berndt <matthias_berndt@…></author> <pubDate>Sun, 02 Dec 2012 08:18:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/973#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/973#comment:12</guid> <description> <p> You're right, it's not as trivial as it seemed. Applying the patch fixes the reference/value semantics, but it breaks the iterator's operator-&gt;. iterator_facade's operator-&gt; assumes that taking a reference's address yields something convertible to value_type*. I'm not sure what this assumption is based upon; I can't see anything in the <a href="http://www.boost.org/doc/libs/1_52_0/libs/iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">New Iterator Concepts</a> that justifies this assumption, but I may have missed something. </p> </description> <category>Ticket</category> </item> </channel> </rss>