DIP 1018--The Copy Constructor--Formal Review

Paul Backus snarwin at gmail.com
Mon Feb 25 22:36:23 UTC 2019


On Monday, 25 February 2019 at 20:41:58 UTC, Paolo Invernizzi 
wrote:
> Honestly, I've not understood the rationale or the covered use 
> case in letting the copy ctor mutate the ref source 
> parameters...
> Sincerely, without polemical intent.
>
> - P

Because D's const is transitive, you can't copy-construct a 
mutable object from a const source:

struct S
{
     int[] stuff;
     this(const ref S source) {
         stuff = source.stuff; // Error: can't assign const(int[]) 
to int[]
     }
}


More information about the Digitalmars-d-announce mailing list