Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-07-26 06:53:43

On Wednesday 26 July 2006 10:48, Georg Baum wrote:

> May I ask why this copy constructor exists at all? With your patch it is
> equivalent to the code the compiler would generate if no copy constructor
> existed. That seems safer to me, because the compiler does not forget to
> initialize members.

You are right, but I prefer not to trust any compiler, especially because so
many are available.

> 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.