Making alias of a struct field needs "this".

realhet real_het at hotmail.com
Tue Jun 2 08:56:13 UTC 2020


Hello,

I have a 2 level nested struct structure with nice descriptive 
field names.
And I thought it will be easy to alias those identifierLists with 
a few letter names and do some calculations on them.
But I'm having an error.

struct A{
   struct B{ int c; }
   B b;

   auto f(){
     alias d = b.c;
     return d;  //Compiler Error: need 'this' for c of type int.
   }
}

There's the this and it's called "b."

Why is this? If I copy paste the aliased expression "b.c", it 
compiled fine.

Thanks in advance!



More information about the Digitalmars-d-learn mailing list