Nordlöw
Nordlöw

Reputation: 12138

C++ Container of Non-Interleaved Stored Tuples

I'm looking for a variant of std::vector or std::array of tuples, where the tuple elements are placed non-interleaved into separate memory areas instead of interleaved as would be the case for, for example, a std::vector<std::tuple<...>>.

The motivations for this is

Iterators should construct and return a boost::tuple<> on-the-fly when dereferenced.

I'm aware that not all STL-member functions could be supported efficiently in this container. For example the STL data() container member function would have to dynamically zip together all the separate arrays into a mutable dynamically created vector container and return its data().

Has anybody constructed such a table container already?

Upvotes: 3

Views: 328

Answers (2)

ildjarn
ildjarn

Reputation: 62975

Boost.Iterator has exactly what you describe: boost::zip_iterator

Upvotes: 4

Mark B
Mark B

Reputation: 96251

What about creating a thin wrapper that supports iteration and a few other operations around a tuple<vector, vector, vector> and representing the data in that way? I'm not aware of any standard container that provides the interface you need.

Upvotes: 1

Related Questions