Boost logo

Boost :

Subject: [boost] interest in structure of arrays container?
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2016-10-14 22:43:27

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>... >;

soa<int,float,std::string> 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:

Does this already exist somewhere?
Does it seem useful?


Boost list run by bdawes at, gregod at, cpdaniel at, john at