Why D const is annoying

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Dec 11 11:35:25 PST 2011


On 12/11/11 12:40 PM, Mafi wrote:
> void f(ref const(int)* a, const(int)* b) {a = b; }
> void main() {
>    immutable(int)* a;
>    auto b = (new int[](5)).ptr;
>    f(a, b);
>    //if this compiles I have just assigned a mutable pointer
>    //to an immutable one
> }

immutable(int)* does not convert to immutable(const)*.

Andrei


More information about the Digitalmars-d mailing list