Boost logo

Ublas :

From: Manoj Rajagopalan (rmanoj_at_[hidden])
Date: 2006-11-18 19:39:27


   I have a function with the prototype:

    template<typename E> void initialize(matrix_expression<E>& A);

When i call this function with:

     matrix<int> A(5, 5);
     initialize(subrange(A, 1, 3, 1, 3));

I get a compiler error (g++ 4.1.0, Fedora Core 5, P4 (i686))

   error: invalid initialization of non-const reference of type
‘matrix_expression<matrix_range<matrix<...> > >&’ from a temporary of
type ‘matrix_range<matrix<...> >’

error: in passing argument 1 of ‘void initialize(matrix_expression<E>&)
[with E = matrix_range<matrix<...> >]’

     Have I made a mistake in my C++? I know matrix_range<> inherits
matrix_expression<matrix_range<>> (CRTP). subrange() generates a
matrix_range<> temporary but why can't I access it using a non-const
reference. I have every intention of modifying the submatrix :-)

Manoj Rajagopalan