3 ms·
To be fair, the same is true of Rust. The issue is that with column-based storage you can't have pointers/references to individual structs within the vector. Y
by zozbot123 8y ago
To be fair, the same is true of Rust. The issue is that with column-based storage you can't have pointers/references to individual structs within the vector. You need to use indexes.
- jgtrosh 8y agoThis is just the old array of structs vs struct of arrays trade-off, right? This is true of pretty much any programming language's low level data structures.
- mamcx 8y agoTell me to me. I try for several months to build a way around this on rust (ie: Have a generic interface to both columnar and row-oriented layout and "just" switch to optimized operations later). I think is impossible. The closest thing is use a NDArray and pick a winner/default layout... that is row-oriented, despite my intention to be columnar first, and later develop an alternate, complete rewrite, for support columnar.
- AstralStorm 8y agoThe thing is, in modern C++ you can fake a wrapper to access it like a pointer or reference. Of course it will not be high performance, but it can be done. (E .g. Eigen library.)
- smitherfield 8y agoWhy wouldn't an implementation along these lines be performant? template<typename... Ts> class SoA : public tuple<vector<Ts>...> { // ... template<size_t... Is> tuple<Ts&...> subscript(size_t i, index_sequence<Is...>) { return {get<Is>(*this)[i]...}; } public: // ... auto operator[](size_t i) { return subscript(i, index_sequence_for<Ts...>{}); } };