lundi 17 décembre 2018

How to apply a meta function to the template types of a variadic template class?

Lets assume I have numerous atomic structs each having an inner_type:

struct Atomic1{
    using inner_type = int;
};
struct Atomic2{
    using inner_type = double;
};
struct Atomic3{
    using inner_type = bool;
};
...

My client class is a variadic template that can use 1 or more of the above atomic classes:

template<class ...AtomicTypeArgPack>
class MyclassAcceptingAtomicTypes;

I have have a related generic class that accepts Atomic*::inner_type as template parameters:

template<class ...InnerTypeArgPack>
class MyclassAcceptingInnerTypes;

My specific api class is defined but specifying a couple of template types:

using my_first_class_t = MyclassAcceptingAtomicTypes<Atomic1, Atomic2>;

for each specific class, I also have another class of inner types:

using my_first_class_inner_types_t = MyclassAccpetingInnerTypes<Atomic1::inner_type ,  Atomic2::inner_type >;

Is there is way to automatically generate the second type (i.e. my_first_class_inner_types_t) from the first declaration (my_first_class_t) using template meta programming / meta functions?

Aucun commentaire:

Enregistrer un commentaire