Closed Char-Aznable closed 6 years ago
No, its more based on boost::zip_iterator
or thrust::zip_iterator
. I wanted to see if you could do a similar thing, but at the container level. That is have a vector container that was really just a zip'ed collection of other vectors (so each variable in Aboria would have its own lower-level vector container). Once the user supplies the type list of variables, you just use some meta-programming techniques to build up your zip container. Aboria enforces that the type list of variables is made up of unique types, so then you can use get<variable>(particles[i])
functions to access a single variable from the particle in index i
.
Good news is that you can build up this zip container easily enough, bad news is that its not 100% STL compatible, in much the same reason that std::vectorvalue_type
of this container is something like std::tuple<T1,T2,T3,...>
, but the reference
is std::tuple<T1&,T2&,T3&,...>
, so the reference
type is not a reference of the value_type
. But saying that, it does work fine for most situations.
That makes sense. Thanks for the explanation.
What's the programming pattern behind Aboria::Particles<>'s capability to handle arbitrary number of types, e.g., position, velocity, id...? Just by skimming the code I found that it's kinda designed similarly to std::variant in c++17 or boost::variant -- just curious, is my guess correct?