I would like to be able to do something like the following:
struct A {};
template<typename T, typename U> struct B : public A {};
std::unique_ptr<A> chooseB(int i, int j)
{
// return B<T, U> where T and U vary with i and j (0 = int, 1 = double etc.)
}
Potentially the list of types could be long enough that just forming a big conditional that enumerates all possible pairs of i and j could be painful.
Is there are nice way to write the chooseB function? I might potentially want to generalize this to more than two template parameters.
Aucun commentaire:
Enregistrer un commentaire