|
Ublas : |
From: Georg Baum (Georg.Baum_at_[hidden])
Date: 2006-07-26 09:09:04
Am Mittwoch, 26. Juli 2006 12:53 schrieb Gunter Winkler:
> You are right, but I prefer not to trust any compiler, especially because
> so many are available.
Are you missing a smiley or do you mean that seriously? If you can't trust
your compiler you are lost anyway IMHO. I would guess that the chance that
you forget to initialize a member like it happend in this case is higher
than the chance of a compiler generating wrong code.
> > Apart from that, what about
> >
> > hermitian_matrix_element &operator = (const hermitian_matrix_element
> > &p)?
> >
> > Does it need to copy i_ and j_ as well?
>
> No, it must not copy i and j. The hermitian_matrix_element behaves like a
> reference, thus the only way to get an exact copy is the copy
> constructor. Assignment of one reference to another means to assign the
> referenced values.
Thanks (also for your other explanation, our mails crossed each other),
reference semantics explain it all.
I know that you did not write this code, but a comment explaining the
reference semantics would be better than the existing
// Construction and destruction
and
// Assignment
. Everbody knows that operator=() is the assignment operator and
~classname() is the destructor ;-)
Georg