Suppose I have in a templated derived class in C++ for which I want to choose template arguments at runtime according to some conditions. Something like:
class Base {
public:
virtual void do_something() = 0;
};
template <typename T, typename U>
class Derived : public Base {
public:
virtual void do_something() { ... }
};
Base* obj;
if (... /* runtime conditon #1 */ )
obj = new Derived<T1, U1>();
else if (... /* runtime condition #2 */ )
obj = new Derived<T1, U2>();
...
obj->do_something();
I'd like to refer to this situation in general, but don't know how to call it. Is there some standard name for it? Is it some kind of design pattern or idiom?