#include <array>
#include <iostream>
#include <experimental/meta>
template <typename T, std::size_t N>
struct struct_of_arrays {
// omitted
// ...
// ...
};
struct point {
float x;
float y;
float z;
};
int main() {
struct_of_arrays<point, 2> p;
p.x = {1.1, 2.2};
p.y = {3.3, 4.4};
p.z = {5.5, 6.6};
std::cout << p.x[0] << ", " << p.x[1] << std::endl; // output: 1.1, 2.2
return 0;
}
Remarks:
For some computations, especially the ones suited for GPU, the SoA memory layout might yield better performance.