The goal is to develop a C++ library that allows to abstract the data layout of an array. Possible data layouts include aray of struct (AoS) and struct of array (SoA), see the following example.
constexpr std::size_t N = 42;
struct Point { int x, y, z; };
Point point_aos[N]; // data layout: AoS
template <std::size_t N>
struct PointSoA {
int x[N];
int y[N];
int z[N];
};
Point<N> point_soa; // data layout: SoA
We aim at writing a class that takes the struct Point, a data layout, and possibly more arguments. The class then allows for AoS access, but stores the data in a possibly different layout, thereby hiding the data layout.
template<
template <class> class F, // container
template <template <class> class> class S, // e.g. "Point"
layout L // data layout
>
struct wrapper;
Reason:
Investigated approaches: