mardi 18 septembre 2018

Is it possible to create a template template parameter list?

I was wondering whether it's possible to make a list containing template template parameters, like

template <
    template <typename...> class... TTPs,
    template <typename...> class TTP0
>
struct TTP_List : TTP_List<TTPs...> {};

A problem I encountered is that I did not know a good way to access the elements of the list, that is, TTP0. I would like to use type aliases, typedef or using. I however know this is not possible, because the template template parameters are not types and must therefor not be treated as such.

A approach I could imagine working is making explicit structs to read the data and make it use specializations, such as:

template <template <typename...> class>
struct container_TTPs;

template <template <typename...> class TTP>
struct container_TTPs<std::vector> {};

However, this approach seems very explicit. Is there a way to accomplish this recognition without this use of template specialization?

Feel free to ask if I need to elaborate.

Aucun commentaire:

Enregistrer un commentaire