Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-04-07 15:02:37


Hi Peter,

you wrote:

> > Yes ;-) I think, the corresponding documentation doesn't state clearly
> > enough, that the assignment of proxies like matrix_range has the same
> > semantics as the assignment of containers, i.e. the referenced elements
are
> > copied but not the references itself.
>
> I'm not sure wether I understand this, shouldn't
>
> TpMatrixRange r1 = TpMatrixRange( U, numerics::range( 0,1),
> numerics::range( 0,1) );
>
> TpMatrixRange r2 = TpMatrixRange( U, numerics::range( 0,1),
> numerics::range( 0,2) );
> r2 = TpMatrixRange( U, numerics::range( 0,1), numerics::range( 0,1) );
>
> or at least
> r2 = r1;
>
> then work ? (At least it doesn't ).
> What is the purpose of the assigment operator then ?

Let me try to explain it another way: proxies like vector_range and
matrix_range implement operator=(), operator+=() and operator-=() with the
same semantics as containers like vectors and matrices. The operations
change instead of whole vectors and matrices the corresponding parts of the
referenced vectors or matrices.

For example:

TpMatrixRange r1( U, numerics::range( 0,1), numerics::range( 0,1) );
TpMatrixRange r2( V, numerics::range( 0,1), numerics::range( 0,1) );
r2 = r1;
r2 += r1;
r2 -= r1;

assigns U(0, 0) to V (0, 0), adds U(0, 0) to V (0, 0) and so on.

> > BTW, the default constructor of matrix_range is currently useless for an
> > application and is therefore not documented.
> Shouldn't it be private/protected then ?

Yes, but we currently need it to be public for concepts.h ;-(

Best regards

Joerg


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