Re: [ublas-dev] Re: unwanted insertion of explicit zeros again
> > From reading your initial posting it seems there were two relatedYes.
> > problems. Firstly incorrect evalution of the expression
> > v1(1) = v1(1) - v1(0);
> > due to reference invalidation
> > And secondly the insertion of the explicit zero.
> Right. I would like to stress that the invalidation problem is not
> I modified my initial code sample to demonstrate that.[snip]
> The code creates a vector v= [ 0 1 2 ], and then creates an iterator
> dviter pointing to v.begin() = v(1) = "1". Then I calculate
> v(0) = v(0) + 42*v(1), so the previously implicit zero value v(0) is
> set to "42". Unfortunately, the iterator isn't updated and still
> points to v.begin(), which is now v(0) instead of v(1).
> VECTOR::iterator viter = v.begin();Here viter may or may not be invalidated depending on the storage type.
> v(0) = v(0) + 42*v(1);
> cout<<*dviter<<endl; //should yield "1"This behaviour probably should be documented.
> cout<<*viter<<endl; //should yield "2"
> return EXIT_SUCCESS;