|
Boost : |
Subject: Re: [boost] [multi_array] Bug in rbegin(), rend()?
From: John Reid (j.reid_at_[hidden])
Date: 2009-05-21 06:04:23
John Reid wrote:
>> On 5/19/09, John Reid <j.reid_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk