Why can't I copy a const struct?

Ali Çehreli acehreli at yahoo.com
Fri Nov 15 11:08:12 PST 2013


On 11/15/2013 10:37 AM, Ali Çehreli wrote:

 >  >          this(this) {
 >  >              a = a.dup;
 >
 > That line can work only if a is mutable. The trouble is, the type of a
 > is const(int[]) there.

I lied! :) The type of a is int[] in there. The actual trouble is, to be 
able to start executing this(this), the left-hand side a should have 
already been a reference to the right-hand side a.

What fails is that initialization of the mutable reference on the 
left-hand side from the const reference on the right-hand side.

Ali



More information about the Digitalmars-d-learn mailing list