Idiomatic way to call base method in generic code

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 25 15:47:11 PDT 2015


On Mon, 25 May 2015 09:24:56 +0000, ZombineDev wrote:

> alias can't refer to a nested member:
> -------------
> struct Point2 {
>      float x;
>      float y;
> }
> 
> struct Line2 {
>      Point2 start;
>      Point2 end;
> 
>      mixin Access;
> 
>      // alias x1 = this.start.x; <- this doesn't work :(
> 
>      alias x1 = get!"start.x";
>      alias y1 = get!"start.y";
>      alias x2 = get!"end.x";
>      alias y2 = get!"end.y";
> }
> 
> // I need to use a mixin to flatten the access :(
> private mixin template Access()
> {
>      ref auto get(string accessPattern)() inout {
>          return mixin(accessPattern);
>      }
> }
> -------------

i wonder if there is a reason for that limitation (except "nobody 
implemented that feature yet", of course).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150525/4a93d1a4/attachment.sig>


More information about the Digitalmars-d-learn mailing list