Possible Duplicate:
Dynamic dispatching of template functions?
I would like to use non-type templates to create grid cells with different memory footprints without having to use dynamically allocated memory on the heap, e.g.
template <int cell_size>
class myCell {...}
There is a finite number of cell sizes (approx. 10), thus I can easily instantiate all of them explicitly. However, which one of the cells are needed is not known at compile time but during runtime only.
I know that templates are a compile-time concept, but is there a way to use templated classes in this way, especially since I can guarantee that all necessary cell types are explicitly instantiated?