A
Avner
Hi,
I am creating a template library for a template class with two template
arguments.
Is there a way to span a suite of explicit instantiation, instead of
having to specify all the combinations of the template arguments
specifically?
Say I have a class
template <class T1, class T2>
class Foo
{
T1 t1;
T2 t2;
}
with T1, T2 having the following possibilities:
T1 - unsigned char, short, unsigned short, long
T2 - unsigned char, short, float, double
I was thinking of some way like a function that scans all the
combinations and constructs the class for each of the combinations.
Maybe having the function as static will force the generation of the
code, which will force the generation of the class code for each
combination of the template arguments.
Something like:
template <class S1, class D>
static void foo()
{
loop on all T1 possibilities
{
loop on all T2 possibilities
{
Foo<T1, T2> *p = new Foo<T1, T2>;
}
}
}
Thanks,
Avner
I am creating a template library for a template class with two template
arguments.
Is there a way to span a suite of explicit instantiation, instead of
having to specify all the combinations of the template arguments
specifically?
Say I have a class
template <class T1, class T2>
class Foo
{
T1 t1;
T2 t2;
}
with T1, T2 having the following possibilities:
T1 - unsigned char, short, unsigned short, long
T2 - unsigned char, short, float, double
I was thinking of some way like a function that scans all the
combinations and constructs the class for each of the combinations.
Maybe having the function as static will force the generation of the
code, which will force the generation of the class code for each
combination of the template arguments.
Something like:
template <class S1, class D>
static void foo()
{
loop on all T1 possibilities
{
loop on all T2 possibilities
{
Foo<T1, T2> *p = new Foo<T1, T2>;
}
}
}
Thanks,
Avner