|
Boost : |
From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-10-04 05:35:27
----- Original Message -----
From: "Toon Knapen" <toon.knapen_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, October 03, 2002 9:38 AM
Subject: [boost] ublas matrix_row<>::operator[] compile error
> 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 ;
> }
This could be a difficult problem AFAIK. I'll try to analyze it later.
Thanks
Joerg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk