Structure of arrays is a pretty well known pattern for improving memory
density and enabling vectorization in high performance code. Also known
as parallel arrays[1].
After hand-rolling yet another of these it occurred to me that you make
a reasonable first implementation with a simple alias template.
template< typename... Ts >
using soa = std::tuple< std::vector<Ts>... >;
example:
soa data;
This is decent start but has several issues including:
* nothing to preserve the invariant keeping the arrays the same length
* missing coalesced interface for vector methods (size, reserve, etc)
* no iterator
* wasted storage for duplicated allocators, capacities, sizes
* sizeof...(Ts) allocations could be a single large block
The work required to address these issues is not too great I think.
Potential names:
soa<Ts>
structure_of_arrays<Ts>
parallel_array<Ts>
struct_array<Ts>
parallel_vector<Ts>
struct_vector<Ts>
Does this already exist somewhere?
Does it seem useful?
[1]https://en.wikipedia.org/wiki/Parallel_array