P
Pierre Yves
Hi there,
Sorry for the double subject but I feel they are related. I'm not pretty
sure there would be an answer but I reckon there must be a way to make
it work.
I would like to write the following bit of code:
8<----------------------------
Foo<> * myFoo = NULL; // Foo is a templated class.
if (condition1) {
myFoo = new Foo<double>(parameters);
} else {
myFoo = new Foo<long>(parameters);
}
processFoo(myFoo);
8<----------------------------
This version is obviously illegal. Have you any ideas for an
alternative? i.e. declaring the template list of my templated class at
run time?
I'm looking for a way to do some run-time polymorphism at run-time with
templates. Can I define the template class is derivated from an other
class (similar to an interface in java) or the template will raise
conflicts? Is there a nicer solution?
Thanks for your help,
PY
Sorry for the double subject but I feel they are related. I'm not pretty
sure there would be an answer but I reckon there must be a way to make
it work.
I would like to write the following bit of code:
8<----------------------------
Foo<> * myFoo = NULL; // Foo is a templated class.
if (condition1) {
myFoo = new Foo<double>(parameters);
} else {
myFoo = new Foo<long>(parameters);
}
processFoo(myFoo);
8<----------------------------
This version is obviously illegal. Have you any ideas for an
alternative? i.e. declaring the template list of my templated class at
run time?
I'm looking for a way to do some run-time polymorphism at run-time with
templates. Can I define the template class is derivated from an other
class (similar to an interface in java) or the template will raise
conflicts? Is there a nicer solution?
Thanks for your help,
PY