Efficient Data Structures

Context

Approach using a skeleton class

 
#include "soa_wrapper.h"
#include "aos_wrapper.h"

#include <iostream>
#include <string>
#include <vector>

template<template <std::size_t, class...> class F, class... Args>
struct S {
F<0, int, Args...> x;
F<1, int, Args...> y;
F<2, double, Args...> activation;
F<3, std::string, Args...> identifier;
};

template <std::size_t, class T>
using my_vector = std::vector<T>;

int main() {
// aos_wrapper::aos_wrapper<my_vector, S> my_array(3);
soa_wrapper::soa_wrapper<my_vector, S> my_array(3);

// AoS access
for (int i = 0; i < 3; ++i) {
my_array[i].x = i - 10;
my_array[i].y = i + 50;
my_array[i].activation = 0.5 * i;
my_array[i].identifier = "foo" + std::to_string(i);
}

// SoA access
my_array.y[1] = 42;
my_array.identifier[2] = "bla";
}

David's variation of this approach

I am about to fill the gabs in David's code following the same approch. The challenges are more or less the same: