const overload

Steven Schveighoffer schveiguy at yahoo.com
Fri Sep 23 13:27:23 PDT 2011


On Fri, 23 Sep 2011 16:19:15 -0400, so <so at so.so> wrote:

> Hello everyone.
>
> I asked this a few times with no response.
> Could anyone explain me what is the rational behind this?
> Why it won't distinguish mutable overload from immutable as in C++?

example?  I'm afraid I don't really understand the question.  overloads  
based on const/immutable are supported:

struct S
{
    void foo() { writeln("mutable");}
    void foo() const { writeln("const");}
    void foo() immutable { writeln("immutable");}
}

void main()
{
    S s;
    immutable(S) s2;
    const(S) s3;
    s.foo();
    s2.foo();
    s3.foo();
}

outputs:

mutable
immutable
const

-Steve


More information about the Digitalmars-d-learn mailing list