Boost logo

Ublas :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-06-02 15:11:26

----- Original Message -----
From: "Michael Stevens" <mail_at_[hidden]>

> I was talking about all operator in general. += and -= can be specialised
> for
> the case where LHS and RHS are of identical type. In this case no aliasing
> can occur. uBLAS already makes this specialisation for operator= in the
> same
> case.
> If you are interested have a look at the assignment definitions in the in
> the
> vector class. Of course any such change would need to be propagated to all
> container types.

Looking briefly at the following code:

        template<class AE>
        vector &operator += (const vector_expression<AE> &ae) {
            // return assign (self_type (*this + ae));
            self_type temporary (*this + ae);
            return assign_temporary (temporary);

it appears to me that simply changing it to:

        template<class AE>
        vector &operator += (const self_type& a) {
           for (int i=size()-1; i >= 0; --i) {
             data_[i] += a.data_[i]

would do the trick.

Christopher Diggins