Incrementally building a typelist in c++

408 Views Asked by At

I am trying to find a way to incrementally build a list of types at compile time that can be used at runtime without an obstructive implementation. The closet solution I have seen is here. The issue for me is the use of the macro since it requires us to add a macro everywhere we define a type we want in our list (error prone and verbose). All of the structures I wish to add to the list will go through a templated function, so ideally if I could build the list there that would solve my issue (no one needs to remember the macro).

I assume the solution is not viable due to the immutable nature of the list (each instantiation of the templated function creates a new list by extending the previous). But my knowledge of template metaprogramming is still limited so possibly there is a feature or technique I have missed.

We are in C++11 so anything there is fine. Boost is available if it helps.

0

There are 0 best solutions below