
John Reid wrote:
On 5/19/09, John Reid <j.reid@mail.cryst.bbk.ac.uk> wrote:
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:
#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 }
This looks to me like a bug in the implementation of the reverse iterator for multi_array. Am I wrong?
The problem only manifests itself when the operator-> is used on the reverse iterator. Replacing begin->end() - begin->begin() with (*begin).end() - (*begin).begin() works fine