Boost logo

Ublas :

Subject: [ublas] vector< T, A >::const_reverse_iterator behavior (bug?)
From: Christian Lyzell (lyzell_at_[hidden])
Date: 2010-02-10 05:17:31


Hej,

I just have come in contact with the boost::ublas library and I am very
impressed by the functionality and the immense work that lies behind it.

I have a question regarding the behavior of the vector< T, A
>::const_reverse_iterator. When I compile the following short program
using g++-4.4

#define BOOST_UBLAS_USE_INDEXED_ITERATOR

#include <iostream>
#include <boost/numeric/ublas/vector.hpp>

int main( void )
{
  using boost::numeric::ublas::vector;
  vector< double > v = vector< double >( 3, 1 );
  {
    vector< double >::const_reverse_iterator it = v.rbegin( );
    for( ; it != v.rend( ); ++it )
      std::cout << *it << " ";
    std::cout << std::endl;
  }
}

I get the following error:

test_ublas_vector.cpp: In function 'int main()':
test_ublas_vector.cpp:11: error: conversion from
'boost::numeric::ublas::reverse_iterator_base<boost::numeric::ublas::indexed_iterator<boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, boost::numeric::ublas::dense_random_access_iterator_tag> >' to
non-scalar type
'boost::numeric::ublas::reverse_iterator_base<boost::numeric::ublas::indexed_const_iterator<boost::numeric::ublas::vector<double,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> >
>, boost::numeric::ublas::dense_random_access_iterator_tag> >' requested
make: *** [test_ublas_vector] Error 1

i.e., the somewhere the compiler wants to convert an indexed_iterator to
an indexed_const_iterator. This error is unexpected from my part and I
am wondering if this is a known bug (could not find it reported
anywhere) and how could it be fixed. This error does not occur when
compiling equivalent code using std::vector.

Best regards,
Christian Lyzell
Linköping, Sweden