mercredi 25 mai 2016

Iterate over types in typelist

I am very new to metaprogramming. I am aware of the C++03 recursive way and of the C++11 variadic template.

Let's say I have this basic typelist : template<class... T> struct TypeList {};

I want to achieve the following :

  • Having a typelist which defines a priority, i.e. the order in which call a function template until it succeeds.
  • Iterate over typelist so I can call the function template which each of the types.

I am currently achieving that in a very ugly way, with a std::vector of std::function which contains instances of the function template in the correct order.

Is it possible in C++ ? Am I misunderstanding something ? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire