Thread overview | |||||
---|---|---|---|---|---|
|
December 09, 2007 Cannot overload on constancy of this | ||||
---|---|---|---|---|
| ||||
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 Re: Cannot overload on constancy of this | ||||
---|---|---|---|---|
| ||||
Posted in reply to Janice Caron | Janice Caron wrote:
> This won't compile:
It's a bug. I'll take care of it.
|
December 09, 2007 Re: Cannot overload on constancy of this | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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!
|
Copyright © 1999-2021 by the D Language Foundation