There is a certain list of types to which you need to add an arbitrary number of types during the compilation process. The target content of the list is not known in advance, since it is determined by the connected header files, here is an example:

typedef LOKI_TYPELIST_1(int) my_list; #include <header_with_types.h> // здесь выполняется какая-то работа с полученным списком. 

The problem is that after executing Loki :: Append <>, it generates a new type list, I just need to change the existing list.

So far I have not been able to find or come up with a solution.

  • An idea arose to apply a radically different approach: instead of using standard compiler tools, generate the necessary code with some third-party tool. But this is the path of sorrow, and the idea arose out of despair. - Spym

1 answer 1

The fact is that changing the type of a list when adding a new type to it is a fundamental property of metaprogramming technology. You can't get away from it. After all, you add a new type to the type (code-named "type list"). Obviously, type + type is a new type. If you look at how this is implemented in locks, I think it will become clear to you why there is no “change” of the existing type, but a change of type. And it also becomes clear that nothing else can be done.

To make it different, you need metatypes. In our case, these are templates, but after all, the template is just here its signature and does not change for another. How was the two-argument and remained)).