I do not understand copy constructors

Learner learner at gmail.com
Thu Aug 12 08:42:27 UTC 2021


I have a structure like, used by other structures:

     struct A {
         int[] data;
         this(this) { data = data.dup; }
     }

I am trying to upgrade it to use copy constructor:

     struct A {
         int[] data
         this(ref return scope A rhs) { data = ths.data.dup; }
     }

     Generating an `inout` copy constructor for `struct B` failed, 
therefore instances of it are uncopyable

What is an `inout` copy constructor? What should I change in A?



More information about the Digitalmars-d-learn mailing list