So I'm trying to come up with a function which converts a;
std::pair<T,std::pair<U, V>>
data type, into a std::tuple
;
std::tuple<T,U,V>
It should work in the general case, with an arbitrary number of mixed type arguments, the format for the pairs is that;
- the 'car' will always be a type,
- the 'cdr' will always be a
std::pair
,- except for the innermost case, where the 'cdr' will be a type itself
(however this might be astd::pair
itself, as the type is arbitrary).
- except for the innermost case, where the 'cdr' will be a type itself
The number and type of arguments I want to retrieve is known in advance, through a variadic template argument.
My current progress is somewhat low, I'm been trying a few things, however it seems like the code I need is along these lines;
std::make_tuple(get<0>(pair), get<0>(get<1>(pair), get<0>(get<1>(get<1>(pair), ..., get<1>(pair)))));
However I can't seem to find a way to automatically generate this, I tried the Sequence<int...>
approach, but without luck, however I do think it's something along those lines that I need to consider, for instance having a get method, which takes a variable number of indexes, and uses these to lookup multiple times, using the ordinary get method?