December 28, 2014 Re: Problem with immutables and Template typeof(this) | ||||
|---|---|---|---|---|
| ||||
Attachments: | On Sun, 28 Dec 2014 14:07:18 -0800 AuoroP via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: let me give you a riddle: struct ExampleTemplate(T) { T value; auto opAdd (typeof(this) that) inout { import std.traits : Unqual; Unqual!(typeof(this)) result; result.value = this.value+that.value; return result; } } alias ExampleTemplate!int Example; void main () { immutable immutableEx = Example(1); Example ex = Example(1); Example ex2 = immutableEx+ex; } i tend to give some explanations to my answers here, but i'm in a strange mood today, so sorry, no explanations this time. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply