standard alias for a class name inside the class code?
jhps via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat May 28 19:44:33 PDT 2016
On Sunday, 29 May 2016 at 00:48:20 UTC, dan wrote:
> Especially in a declaration like
> static typeof(this) make_instance( )
> but also in the 'new typeof(this)'. In both cases, 'this'
> doesn't even exist.
https://dlang.org/spec/declaration.html#Typeof
it's another 'this' that has not the same semantic as the
reference holder.
Just like 'const' can have 3 meanings, 'this' also:
- this.member: typical usage, it hold the instance reference
- void foo(this T)(): template this parameter, T is typeof(this)
where the template is used.
- typeof(this): you can use it in static func, this 'this' is not
the 'this' instance.
More information about the Digitalmars-d-learn
mailing list