I am using [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) as a linear algebra package. There they have fixed size matrix types, defined something like:

```
template<class TNumber, size_t N, size_t M>
class Matrix
{...}

```

so becasue I am using only vectors and square matrices, most of my classes ended up being similar templates:

```
template<size_t K>
class MyClass {...}

```

The dimension K will actually depend on data loaded from a file. Is there any reasonable way to instantiate these templates with a dynamic size K, or do I have to have a switch statement:

```
switch(dim) {
case 1: MyClass<1>...
case 2: MyClass<2>...

default: //too much data
}

```

?