February 05, 2013 Re: x.RC.__postblit () is not callable using argument types () const | ||||
---|---|---|---|---|
| ||||
Posted in reply to Maxim Fomin | On Tuesday, 5 February 2013 at 16:36:16 UTC, Maxim Fomin wrote: > This does not imply such situation, simply there is a problem. You can workaround by > [snip] > struct RC { > int i; > void postblit() { i = -5; } > this(this) const > { > void delegate() dg = &postblit; > dg(); > } > } Great thanks. I'll try. But why does this even code work? I would have thought const guarantee would prevent calls to non-const postblit function. I was under impression this(this) const does not work - but maybe that has changed with 2.061. What source (lang spec, TDPL, or newsgroup) led you to this solution and for how long will it be valid? Where can I read more on it? Thanks Dan |
February 05, 2013 Re: x.RC.__postblit () is not callable using argument types () const | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | On Tuesday, 5 February 2013 at 17:05:23 UTC, Dan wrote: > But why does this even code work? I would have thought const guarantee would prevent calls to non-const postblit function. I was under impression this(this) const does not work - but maybe that has changed with 2.061. Forgot to mention, it works on 2.061. > What source (lang spec, TDPL, or newsgroup) led you to this solution and for how long will it be valid? Where can I read more on it? > > Thanks > Dan Const postblit worked at least at 2.060. Originally idea was to make const cast on function call, but at a current time it is not needed. May be another bug. |
Copyright © 1999-2021 by the D Language Foundation