vendredi 3 août 2018

Extract template template parameter and variadic template parameter from class template

Given the following class template:

template <template <typename... Args> class Container, typename... Args>
struct container_type_holder {};

I would like to extract its template template parameter and its variadic parameter to reuse in another context. Example:

using c1 = container_type_holder<std::map, std::string, int>;
using c2 = container_type_holder<tt_parameter<c1>, vt_parameter<c1>>;

Where tt_parameter<c1> is some magic trick to extract the template template parameter from c1 and vt_parameter<c1> to extract its variadic template parameter.

In order to extract the template template parameter I tried to add an alias inside container_type_holder, but that didn't work because it is not a complete type. To extract the variadic template parameter I tried the same strategy but with no success.

template <template <typename... Args> class Container, typename... Args>
struct container_type_holder 
{
    using container = Container; // doesnt work
    using args = Args...; // ???
};

I don't know if this is possible or not, I'm a begginer in the template world.

Aucun commentaire:

Enregistrer un commentaire