You want a std::vector
of boost::variant
, or a hand rolled equivalent.
Doing what you asked at compile time with tuple
s results in exponential bloat and is rarely the right thing to do. While I could write code that takes arrays of up to size 10 with up to 10 elements and calls a function with a custom tuple, the resulting 10 billion generated functions would blow up your compiler: and unless you want every function in your binary to also be 10 billion times larger, we would have to type erase the result anyhow.
As a general rule, use dynamic structures for dynamic data: we have a dynamic length, so vector
, and the data is of run time typed from a finite set, so variant
.