On Tue, 08 Nov 2011 02:08:27 +0100, Walter Bright <[email protected]> wrote:

http://drdobbs.com/blogs/cpp/231902461

Anyone want to do the reddit honors?

I personally find it much more astonishing that inout methods finally work.

All of this with one method definition, without const_cast macros, without overload ambiguities
but with transitive qualifier safety.

----
import std.stdio;

class C
{
    inout(int) foo() inout
    {
        return a;
    }
    int a;
}

void printType(T)(T t)
{
    writeln(typeid(t.foo()));
}

void main()
{
    auto a = new immutable(C)();
    auto b = new C();

    printType!(immutable C)(a);
    printType!(const C)(a);
    printType!(const C)(b);
    printType!(C)(b);
}

Reply via email to