Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-10-03 02:38:26


Following code snippet demonstrates you can't get an element out of a
matrix_row (using operator[]) on a const_matrix without making the matrix_row
itself const (tested on gcc-3.2). Should'nt a
const matrix_row< const matrix< double > > be equivalent to a
matrix_row< const matrix< double > > ?

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>

int main() {
  using namespace boost::numeric::ublas ;

  matrix< double > a(1,1);
  const matrix< double > ca( a );

  matrix_row< matrix< double > > row_a( a, 0 );
  matrix_row< const matrix< double > > row_ca( ca, 0 );
  const matrix_row< const matrix< double > > crow_ca( ca, 0 );

  double b = row_a[0]; // compiles OK
  double cb = row_ca[0]; // COMPILE ERROR
  double ccb = crow_ca[0]; // compiles OK

  return 0 ;
}

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk