How to break const
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Jun 18 07:39:21 PDT 2012
On 6/18/12 2:14 AM, Mehrdad wrote:
> Okay, how about this? http://ideone.com/VMlzS
>
> Does this break const?
>
>
> import std.stdio;
> class S
> {
> this(int a)
> {
> this.a = a;
> this.increment = { this.a++; };
> }
> int a;
> void delegate() increment;
> void oops() const { this.increment(); }
> }
> void main()
> {
> auto c = new const(S)(0);
> writeln(c.a);
> c.oops();
> writeln(c.a);
> }
Yes. Currently the constructor is not typechecked properly. Kenji has
done some work on that and is still blocked by me and Walter with some
questions.
Andrei
More information about the Digitalmars-d
mailing list