I have a sort of dynamic tuple structure:
template <typename... Elems> //Should only be tuples
class DynamicTuple {
vector<byte> data; //All data is stored contiguously
vector<tuple<size_t,size_t>> element_table; //First element is offset into the data vector; second is which index of the parameter pack holds the stored type.
/* ... */
}
Now I want to be able to filter out all tuples that contain a list of types.
template <typename... Ts>
vector<tuple<Ts&...>> filter() {
vector<tuple<Ts&...>> result;
for (auto it : element_table) {
auto [offset, type] = it;
// ???
}
}
Here I need to be able to check if the type in the Nth index of the "Elems" parameter pack is a tuple that contains all the types in the "Ts" parameter pack. If it does, I want to push back a tuple containing those values.
Intuitively I want to use the "type" value to get the type from the "Elems" parameter pack, and use a has_type structure like the one from this answer: https://stackoverflow.com/a/41171291/11463887 Something like:
((has_type<Ts, tuple_element<type, tuple<Elems...>>::type>&& ...))
However this doesn't work, since "type" is not a compile-time constant expression. Is there a way to get around this?