Follow-up on creation of AoS proxies for SIMDWrapper
The following discussion from !1913 (merged) should be addressed:
-
@graven started a discussion: (+1 comment) How about adding a proxy representing a 'row' -- something like this -- and an iterator which, when dereferenced returns a proxy? If you look at the above link to godbolt, you'll see that that still generates identical code for the following two ways of using a SOA container of tracks:
float sum_pt(const Tracks& trks) { return std::accumulate(trks.begin(),trks.end(),0.f, [](float s, const auto& trk ) { return s+trk.pt(); } ); } float sum_pt_(const Tracks& trks) { float s = 0; int sz = trks.size(); for (int i=0;i<sz;++i) s+=trks.pt(i); return s; }
i.e. the entire proxy & iterator abstraction has absolutely zero overhead, and it does allow one to continue to pretend as if there is no SOA storage... so it's the best of both worlds.