Interesting work on packing tuple layout
Andrej Mitrovic
andrej.mitrovich at gmail.com
Mon Jun 15 06:06:40 UTC 2020
On Saturday, 13 June 2020 at 19:11:33 UTC, Andrei Alexandrescu
wrote:
> https://github.com/ZigaSajovic/optimizing-the-memory-layout-of-std-tuple
>
> Would be interesting to adapt it for std.tuple.
I can't see any way of making indexing work *except* by adding a
Get template inside the tuple.
Currently Tuple supports indexing via `tuple[2]` => gets you the
third value with its own type.
We cannot use opIndex for this because the tuple can consist of
multiple types, and index is a runtime parameter when opIndex is
called.
Now if we had something like `staticOpIndex` in the language
maybe it could work. I could envision it being something like
this:
```
struct Tuple (T...)
{
T t;
auto staticOpIndex (size_t index)() // CT param
{
return t[index]; // or the rearranged index if fields
are re-ordered
}
}
```
More information about the Digitalmars-d-announce
mailing list