mardi 15 mars 2022

Infer types of template template parameter

I need to deduce the typenames of a parameter template. Those parameters would then be used with reflection to achieve my goal. So far I have come up with the following which seems to work:

template <typename... F, typename T>
static void templateA(T t) {
/* Use reflection to obtain the types in F */
}

Which would then be called like this:

template <typename T>
void templateB() {
/* Do some work */
}

templateA<float>(templateB<float>);

This works but I was wondering if it is possible to infer the types of template B from F? I'm trying template template parameters but so far it's not working. Something like this:

template <typename... F, template<typename V> class T>
static void templateA(T<F...> t) {
/* Use reflection to obtain the types in F */
}

templateA<float>(templateB);

Is this possible. I understand this is a bit confusing use case but would appreciate any tips on how to achieve this.





Aucun commentaire:

Enregistrer un commentaire