Boost C++ Libraries: Ticket #3077: Reverse iterator compile-time bug in multi_array https://svn.boost.org/trac10/ticket/3077 <p> I'm having some trouble iterating over a 2-dimensional multi_array in reverse order. I'm using boost 1.38 with gcc-4.2.4 and the following code won't compile with the error given below: </p> <pre class="wiki">#include &lt;boost/multi_array.hpp&gt; template&lt; typename It &gt; void iterate_over( It begin, It end ) { while( end != begin ) { begin-&gt;end() - begin-&gt;begin(); ++begin; } } void test() { boost::multi_array&lt; double, 2 &gt; m; iterate_over( m.begin(), m.end() ); // works fine iterate_over( m.rbegin(), m.rend() ); // causes error } </pre><p> This looks to me like a bug in the implementation of the reverse iterator for multi_array. Am I wrong? It is only a problem when iterator::operator-&gt; is used. The (*begin). notation works fine. </p> <p> /home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp: In static member function ‘static typename boost::mpl::if_&lt;boost::is_reference&lt;Reference&gt;, Pointer, boost::detail::operator_arrow_proxy&lt;<a class="missing wiki">ValueType</a>&gt; &gt;::type boost::detail::operator_arrow_result&lt;<a class="missing wiki">ValueType</a>, Reference, Pointer&gt;::make(Reference) [with <a class="missing wiki">ValueType</a> = boost::multi_array&lt;double, 1ul, std::allocator&lt;double&gt; &gt;, Reference = boost::detail::multi_array::sub_array&lt;double, 1ul&gt;, Pointer = boost::multi_array&lt;double, 1ul, std::allocator&lt;double&gt; &gt;*]’: /home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp:648: instantiated from ‘typename boost::detail::operator_arrow_result&lt;typename boost::detail::iterator_facade_types&lt;Value, <a class="missing wiki">CategoryOrTraversal</a>, Reference, Difference&gt;::value_type, Reference, typename boost::detail::iterator_facade_types&lt;Value, <a class="missing wiki">CategoryOrTraversal</a>, Reference, Difference&gt;::pointer&gt;::type boost::iterator_facade&lt;I, V, TC, R, D&gt;::operator-&gt;() const [with Derived = boost::reverse_iterator&lt;boost::detail::multi_array::array_iterator&lt;double, double*, mpl_::size_t&lt;2ul&gt;, boost::detail::multi_array::sub_array&lt;double, 1ul&gt; &gt; &gt;, Value = boost::multi_array&lt;double, 1ul, std::allocator&lt;double&gt; &gt;, <a class="missing wiki">CategoryOrTraversal</a> = boost::detail::iterator_category_with_traversal&lt;std::input_iterator_tag, boost::random_access_traversal_tag&gt;, Reference = boost::detail::multi_array::sub_array&lt;double, 1ul&gt;, Difference = long int]’ src/sandbox/seqan_sandbox.cpp:12: instantiated from ‘void iterate_over(It, It) [with It = boost::reverse_iterator&lt;boost::detail::multi_array::array_iterator&lt;double, double*, mpl_::size_t&lt;2ul&gt;, boost::detail::multi_array::sub_array&lt;double, 1ul&gt; &gt; &gt;]’ src/sandbox/seqan_sandbox.cpp:22: instantiated from here /home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp:326: error: no matching function for call to ‘implicit_cast(boost::detail::multi_array::sub_array&lt;double, 1ul&gt;*)’ </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3077 Trac 1.4.3 John Reid <j.reid@…> Tue, 09 Jun 2009 12:09:36 GMT <link>https://svn.boost.org/trac10/ticket/3077#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3077#comment:1</guid> <description> <p> Just wanted to correct my email address: j.reid@… </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Tue, 08 Jun 2010 22:51:47 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/3077#comment:2 https://svn.boost.org/trac10/ticket/3077#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Ronald Garcia</span> to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> This is unrelated to reverse_iterator; the forward direction of the traversal fails to compile for me for the same reason. The patch to Boost.Iterator in ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4313" title="#4313: Bugs: operator_arrow_result should use Reference instead of ValueType in ... (closed: duplicate)">#4313</a> (along with the change to <a class="missing wiki">MultiArray</a> in <a class="changeset" href="https://svn.boost.org/trac10/changeset/62604" title="Changed to Boost.Iterator operator_arrow_proxy">r62604</a>) will fix this. </p> Ticket