Thread overview
Cannot overload on constancy of this
Dec 09, 2007
Janice Caron
Dec 09, 2007
Walter Bright
Dec 09, 2007
Janice Caron
December 09, 2007
This won't compile:

    class A
    {
        int[] a;
        this() { a.length = 1; }

        int* ptr() { return a.ptr; }
        const const(int)* ptr() { return a.ptr; }
        invariant invariant(int)* ptr() { return a.ptr; }
    }

    void main()
    {
    	invariant A = cast(invariant)new A;
    }

The compile errors are:

main.d(8): function main.A.ptr conflicts with function main.A.ptr at main.d(7)
main.d(9): function main.A.ptr conflicts with function main.A.ptr at main.d(7)

The compiler appears to be telling me that const ptr() conflicts with
ptr(). Why?

This would be perfectly acceptable in C++. Why can't I say it in D?

Likewise, the compiler complains that invariant ptr() conflicts with
ptr(). Again I say: no it doesn't.
December 09, 2007
Janice Caron wrote:
> This won't compile:

It's a bug. I'll take care of it.
December 09, 2007
On 12/9/07, Walter Bright <newshound1@digitalmars.com> wrote:
> It's a bug. I'll take care of it.

Cool! Thank you, that's brilliant!