Question:
How can an element of a type listusing L = type_list<T1, T2, ...>
be retrieved by index, like std::tuple_element, preferrably in a non recursive way?I want to avoid using tuples as type lists for use cases, that require instantiation for passing a list like
f(L{})
.std::integral_constant
version of the index is a good aproach.Answer:
I want to avoid using tuples as type lists for use cases, that require instantiation for passing a list like f(L{})
If you don’t want to instanciate
std::tuple
but you’re ok with it in
unevaluated contexts, you may take advantage of std::tuple_element
to
implement your typeAt
trait:If you have better answer, please add a comment about this, thank you!