Boost logo

Boost :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-02-22 08:25:24


the patch I quickly made locally for this looks like :

Index: matrix_pr.h
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/Attic/matrix_pr.h,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 matrix_pr.h
--- matrix_pr.h 11 Feb 2002 21:39:02 -0000 1.1.2.7
+++ matrix_pr.h 22 Feb 2002 13:00:28 -0000
@@ -25,6 +25,25 @@

 namespace numerics {

+
+ template < typename M >
+ class matrix_traits
+ {
+ typedef typename M::const_reference const_reference;
+ typedef typename M::reference reference;
+ typedef typename M::const_pointer const_pointer;
+ typedef typename M::pointer pointer;
+ };
+
+ template < typename M >
+ class matrix_traits< const M >
+ {
+ typedef typename M::const_reference const_reference;
+ typedef typename M::const_reference reference;
+ typedef typename M::const_pointer const_pointer;
+ typedef typename M::const_pointer pointer;
+ };
+
     // Matrix based row vector class
     template<class M>
     class matrix_row:
@@ -35,10 +54,11 @@
         typedef typename M::size_type size_type;
         typedef typename M::difference_type difference_type;
         typedef typename M::value_type value_type;
- typedef typename M::const_reference const_reference;
- typedef typename M::reference reference;
- typedef typename M::const_pointer const_pointer;
- typedef typename M::pointer pointer;
+ typedef typename matrix_traits< M >::const_reference
 const_reference; + typedef typename matrix_traits< M >::reference
 reference;
+ typedef typename matrix_traits< M >::const_pointer const_pointer;
+ typedef typename matrix_traits< M >::pointer pointer;
+
 #ifdef NUMERICS_ET_CLOSURE_REFERENCE
         typedef const vector_const_reference<const matrix_row<matrix_type> >
const_closure_type;
         typedef vector_reference<matrix_row<matrix_type> > closure_type;

> to create the equivalent of the, now obsolete, const_matrix_row_type, I now
> create a numerics::row< const Matrix >. But using its operator()(int i), a
> get an error of assinging a const double to a double&. AFAICT, this is
> because the row< const Matrix >::reference takes reference of the template
> argument which ends up being a Matrix::reference. Should'nt a traits class
> handle the `const Matrix` argument and make the reference const ?

-------------------------------------------------------


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