"this" member for structs with methods

Maxim Fomin maxim at maxim-fomin.ru
Sun Mar 17 06:30:28 PDT 2013


On Sunday, 17 March 2013 at 12:16:08 UTC, simendsjo wrote:
> When a struct contains methods, __traits(allMembers reports a 
> member called "this". What is "this"?
>
> void main() {
>     struct S { int i; }
>     struct A { int i; void f() {} }
>     pragma(msg, __traits(allMembers, S)); // i
>     pragma(msg, __traits(allMembers, A)); // i, f, this
> }

This is context pointer. Move outside of function to not to have 
it.


More information about the Digitalmars-d-learn mailing list