Implicitly converting a newly allocated array to immutable

Meta jared771 at gmail.com
Sun Jan 5 17:19:47 PST 2014


The following doesn`t work:

immutable(string[]) strArr = new string[](10);

But I feel that it probably should work. I know we have 
assumeUnique, but I remember awhile ago that some work was done 
toward making the result of unique expressions (like those using 
new) implicitly convertible to immutable, const, shared, etc. For 
example, the following works:

class Test
{
     int i;
}

immutable(Test) test = new Test();

(I realize that this will break if Test contains any non-value 
type like an array)


More information about the Digitalmars-d-learn mailing list