Consider this struct:

---
Foo
{
    uint a,b,c;
    float d,e,f;
}
---

in a collection:

---
Foo[] foos;
---

Looping a particular member is not cache friendly

---
foreach(foo;foos){/*foo.a = ...*/}
---

but to write clear, understable, structured code, the struct is necessary.

So, is it possible to imagine an abstraction such as

---
FooData
{
    uint[] a,b,c;
    float[] d,e,f;
    Foo[] items(){}
}
---

that would allow to loop over the data in a cache-friendly way ?
You think that an item as the member but they are actually stored using another memory layout ?

A template for this would be particularly usefull:

template DataFriendlyStruct(T) if (is(T==struct) && isPOD!T)
{
   alias DataFriendlyStruct = ...
}

Reply via email to