On Tuesday, 7 September 2021 at 17:47:15 UTC, james.p.leblanc
wrote:
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
from what I understand you want to change the aligned data that
you're referring to at runtime.
```d
void main()
{
import std.experimental.allocator.mallocator;
import std.stdio: write, writeln, writef, writefln, readf;
uint alignment, length;
readf!"%u %u"(length,alignment);
auto buffer =
AlignedMallocator.instance.alignedAllocate(length,
alignment);
writeln(&buffer[0]);
scope(exit) AlignedMallocator.instance.deallocate(buffer);
//...
}
```
Is this it?