C++ parameter pack of parameter packs?

85 Views Asked by At

My objective is to build type lists by merging. The ultimate goal is to build a compile time type dependency library.

Is it possible to construct parameter packs of parameter packs in C++?



// definition of a type list
template <typename...> struct sektyp;

template <> struct sektyp<> {};

template <typename Head, typename... Tails> struct sektyp<Head, Tails...> {
    using head = Head;
    using tails = sektyp<Tails...>;
};

// merge two type lists
template <typename... ST1, typename... ST2>
struct sektypmerge<sektyp<ST1...>, sektyp<ST2...>> {
    using result_type = sektyp<ST1..., ST2...>;
};

// merge three type lists 
template <typename... ST1, typename... ST2,typename... ST3>
struct sektypmerge<sektyp<ST1...>, sektyp<ST2...>,sektyp<ST3...> {
    using result_type = sektyp<ST1..., ST2...,ST3...>;
};

// merge N type lists...?

Merge N lists:

using integers = sektyp<int, unsigned>;
using reals = sektyp<float, double>;
using strings = sektyp<std::string>;
using irs=sektypmerge<integers,reals,strings>::result_type;

Now instead of integers, reals, strings you have 134 type lists. How do you do it?

EDIT: float (not short, of course)

Thank you

Tried several type list libraries on Github and Stackoverflow, but none could merge an arbitrary number of type lists.

0

There are 0 best solutions below