See title. I have a template. I want to force a particular instance of a template to instantiate. How do I do this?
More specifically, can you force an abstract temp
You can force instantiation by using the template with the desired parameter. For example you could define a function using all the required methods:
void force_int_instance() {
Abstract *a;
a->some_method();
a->some_other_method(1, 2, 3);
}
You don't need to actually call that function anywhere, so it's not a problem that the pointer is not initialized. But the compiler has to assume that the function might be called from another object file, so it has to instantiate the template.