On Saturday, 26 March 2016 at 20:55:17 UTC, maik klein wrote:
[snip]
Thanks, yes that is simpler.
But I am not sure that I want to have pluggable containers in
SOA, mostly because every field would have overhead from the
container.
For example array has size, length etc as overhead, but it is
also not that much and probably won't matter anyway.
But I also thought about it, maybe sometimes I want to use a
map instead of an array for some fields. So I need to have a
way of telling which field should get which container.
Maybe something like this:
SOA!(Foo, Array, HashMap, DList);
The current implementation is mostly for experimentation.
Never mind. Anything with memory representation different from an
array would ruin cache locality. My thinking was that using a
container defined somewhere else would simplify the code.
I tried a couple approaches and came up with the following, which
I think this is the most efficient in terms of space overhead and
number of allocations (but still generic), implementation that is
possible:
http://dpaste.dzfl.pl/3de1e18756f8
It took me a couple of tries, but overall I'm satisfied my code,
although is it's more low-level and more meta-heavy than yours.