digitalmars.D - Cannot overload on constancy of this
- Janice Caron (21/21) Dec 09 2007 This won't compile:
- Walter Bright (2/3) Dec 09 2007 It's a bug. I'll take care of it.
- Janice Caron (2/3) Dec 09 2007 Cool! Thank you, that's brilliant!
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.
Dec 09 2007
Janice Caron wrote:This won't compile:It's a bug. I'll take care of it.
Dec 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!
Dec 09 2007