On Friday, 7 June 2013 at 16:33:50 UTC, monarch_dodra wrote:
On Friday, 7 June 2013 at 16:24:16 UTC, monarch_dodra wrote:
I seem to specifically remember that it *didn't* work this way. Isn't this a regression?

...and I seem to have been wrong. This has never worked.

And I can also confirm that C++ does strip the top level const in this case.

I agree, it would be nice for D to do this too.

Ack, it appears it is only done for arrays and pointers :-S

string foo(T)(T x)
{
        return T.stringof;
}

void main()
{
        class C {}
        const int[] a;
        const int* b;
        const C c;
        const int d;

        import std.stdio;
        writeln(foo(a)); // const(int)[]
        writeln(foo(b)); // const(int)*
        writeln(foo(c)); // const(C)
        writeln(foo(d)); // const(int)
}

Obviously you can't strip anything from (c), but I have no idea why (d) isn't stripped. This is bizarre.

... or is this because of the const postblit problem?

Reply via email to