mercredi 13 juillet 2022

How to write a wrapper around a templated class that modifies the template parameters in C++?

template<typename T> class A {
};
template<typename T> class A1: public A<T>{
};
template<typename T> class A2: public A<T>{
};

We have a templated class A and derived classes A1 and A2.

Now I need a wrapper that accepts any class of type A* i.e any derived type of A, as a template parameter and modify its template parameter

template<typename T, typename Atype> class WrapperA {
   Atype<pair<T, int>> atypeobj;
};

Hoping to be used as follows

WrapperA<int, A1<int>> w1;
WrapperB<int, A2<int>> w2;

The WrapperA needs to work only with derived classes of A

Aucun commentaire:

Enregistrer un commentaire