Static indexing

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 12 17:12:06 UTC 2022


On Wed, Jan 12, 2022 at 11:04:59AM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 1/12/22 3:59 AM, JG wrote:
[...]
> >      struct Point
> >      {
> >        double x;
> >        double y;
> >        alias expand = typeof(this).tupleof;
> >        alias expand this;
> >      }
[...]
> I was going to reply that you can't do it this way, but it works. Very
> interesting!
> 
> I would say to go with that, and I love that technique! Seems like it
> started allowing alias to `tupleof` in 2.094.
[...]

Yeah, I was also going to say, this is a very interesting trick indeed!
I might actually adopt this for one of my projects, instead of the more
complex CTFE-generated mixin I'm currently using.


T

-- 
Making non-nullable pointers is just plugging one hole in a cheese grater. -- Walter Bright


More information about the Digitalmars-d-learn mailing list