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 <boost/multi_array.hpp>
template< typename It >
void
iterate_over( It begin, It end )
{
while( end != begin ) {
begin->end() - begin->begin();
++begin;
}
}
void
test()
{
boost::multi_array< double, 2 > 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-> 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_<boost::is_reference<Reference>, Pointer, boost::detail::operator_arrow_proxy<<a class="missing wiki">ValueType</a>> >::type boost::detail::operator_arrow_result<<a class="missing wiki">ValueType</a>, Reference, Pointer>::make(Reference) [with <a class="missing wiki">ValueType</a> = boost::multi_array<double, 1ul, std::allocator<double> >, Reference = boost::detail::multi_array::sub_array<double, 1ul>, Pointer = boost::multi_array<double, 1ul, std::allocator<double> >*]’:
/home/john/Dev/ThirdParty/boost/boost_1_38_0/boost/iterator/iterator_facade.hpp:648: instantiated from ‘typename boost::detail::operator_arrow_result<typename boost::detail::iterator_facade_types<Value, <a class="missing wiki">CategoryOrTraversal</a>, Reference, Difference>::value_type, Reference, typename boost::detail::iterator_facade_types<Value, <a class="missing wiki">CategoryOrTraversal</a>, Reference, Difference>::pointer>::type boost::iterator_facade<I, V, TC, R, D>::operator->() const [with Derived = boost::reverse_iterator<boost::detail::multi_array::array_iterator<double, double*, mpl_::size_t<2ul>, boost::detail::multi_array::sub_array<double, 1ul> > >, Value = boost::multi_array<double, 1ul, std::allocator<double> >, <a class="missing wiki">CategoryOrTraversal</a> = boost::detail::iterator_category_with_traversal<std::input_iterator_tag, boost::random_access_traversal_tag>, Reference = boost::detail::multi_array::sub_array<double, 1ul>, Difference = long int]’
src/sandbox/seqan_sandbox.cpp:12: instantiated from ‘void iterate_over(It, It) [with It = boost::reverse_iterator<boost::detail::multi_array::array_iterator<double, double*, mpl_::size_t<2ul>, boost::detail::multi_array::sub_array<double, 1ul> > >]’
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<double, 1ul>*)’
</p>
en-usBoost C++ Libraries/htdocs/site/boost.png
https://svn.boost.org/trac10/ticket/3077
Trac 1.4.3John 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