Curious effect with traits, meta, and a foreach loop ... mystifies me.
james.p.leblanc
james.p.leblanc at gmail.com
Tue Sep 7 17:47:15 UTC 2021
On Tuesday, 7 September 2021 at 17:33:31 UTC, Adam D Ruppe wrote:
> On Tuesday, 7 September 2021 at 17:24:34 UTC, james.p.leblanc
> wrote:
>
> If you want to do a runtime lookup, you need to separate the
> two pieces. This pattern works:
>
>
> switch(runtime_index) {
> foreach(i, val; item.tupleof)
> case i:
> // use val
> }
>
> So the switch is at runtime but the loop and cases are all
> known at compile time.
Adam,
Thanks for the very fast, and very thorough explanation. I
especially
appreciate the fact that you seem to have predicted where my
thoughts
were heading with my experiments ...
The "switch(runtime_index)" snippet will come in handy ...
What I would **REALLY** like is to be able to do (but I think
this is
impossible) would be to "dig out" the needed "x" array depending
on
which one of them suits my alignment needs. (Yes, I am still
playing
with avx2 ideas ...).
What I mean by "dig out" the needed "x" is: if I could
alias/enum/
or someother trick be then able just to use that "x" as a simple
static array.
(I doubt this is possible ... but .... ?).
Thanks again, Keep Warm in Upstate!
James
More information about the Digitalmars-d-learn
mailing list